Re: Machine Level Exception Error
- Posted by andreasWagner 1 week ago
- 142 views
jmduro said...
I corrected AG_Initcore as such:
public function AG_InitCore(object progname, integer flags) atom addr, ret if sequence(progname) then addr = allocate_string(progname) else addr = progname end if ret = c_func(xAG_InitCore, {addr, flags}) return ret end function
I still get the same error when running this piece of code:
if (AG_InitCore("dummy", 0) = -1) or (AG_InitGraphics(0) = -1) then printf(2, "Init failed: %s\n", {AG_GetError()}) maybe_any_key() abort (1) end if
The error happens when running AG_InitGraphics(0) or AG_InitGraphics(allocate_string("dummy")).
Jean-Marc
Hi,
i basicly did the same and got it to work
atom gui = open_dll("ag_gui.dll") atom core = open_dll("ag_core.dll") ?core ?gui public constant xAG_InitCore = define_c_func(core,"+AG_InitCore",{C_POINTER,C_UINT},C_INT) public function AG_InitCore(object name,atom flags) return c_func(xAG_InitCore,{name,flags}) end function public constant xAG_InitGraphics = define_c_func(gui,"+AG_InitGraphics",{C_POINTER},C_INT) public function AG_InitGraphics(object driver) atom dummy=0,result if sequence(driver) then dummy=allocate_string(driver) driver=dummy end if result = c_func(xAG_InitGraphics,{driver}) if dummy then free(dummy) end if return result end function if AG_InitCore(NULL,0) = -1 then puts(1,"Failed to init AGAR!\n") abort(1) end if if AG_InitGraphics("WGL") = -1 then puts(1,"Failed to init Graphics!\n") abort(1) end if
But i had some dll missing on my system before i got this far.
it took me a while
13.12.2024 14:56 562.176 libfreetype-6.dll 13.12.2024 16:15 151.731 libgcc_s_seh-1.dll 13.12.2024 16:00 920.576 libjpeg-8.dll 13.12.2024 16:02 247.390 libpng16-16.dll 13.12.2024 16:05 338.088 libwinpthread-1.dll 13.12.2024 16:12 103.256 zlib1.dllPassing Null seems the way to go according to the documentation
If the drivers argument is NULL (the usual case), Agar selects the "best" driver available on the current platform.
Maybe this helps (btw i used Phix for this)
Andreas