MGRX Wrapper
- Posted by Icy_Viking 3 days ago
- 80 views
Hi all,
Thanks to AI. I was able to successfully a DLL for the MGRX library and make a wrapper. However it is very wonky while working under windows.
--some wrapper code public constant GR_frameDriver = define_c_struct({ C_INT, --mode C_INT, --rmode C_INT, --is_video C_INT, --row_align C_INT, --num_planes C_INT, --bits_per_pixel C_LONG, --max_plane_size C_POINTER, --md C_POINTER, --c C_INT, --x C_INT, --y C_INT, --x C_INT, --y C_UINT, --GrColor c C_INT, --x C_INT, --y C_INT, --dx C_INT, --dy C_UINT, --grColor c C_INT, --x C_INT, --y C_INT, --w C_UINT, -- grcolor C_INT, --x C_INT, --y C_INT, --h C_UINT, --grcolor C_INT, --x C_INT, --y C_INT, --w C_INT, --h C_UINT, --grcolor C_INT, --x C_INT, --y C_INT, --w C_INT, --h C_POINTER, --bmp C_INT, --pitch C_INT, --start C_UINT, --fg C_UINT, --fg C_INT, --x C_INT, --y C_INT, --w C_CHAR, --patt C_UINT, --fg C_UINT, --bg C_POINTER, --dst C_INT, --dx C_INT, --dy C_POINTER, --src C_INT, --x C_INT, --y C_INT, --w C_INT, --h C_UINT, --op C_POINTER, --dst C_INT, --dx C_INT, --dy C_POINTER, --src C_INT, --x C_INT, --y C_INT, --w C_INT, --h C_UINT, --op C_POINTER, --dst C_INT, --dx C_INT, --dy C_POINTER, --src C_INT, --x C_INT, --y C_INT, --w C_INT, --h C_UINT, --op C_POINTER, --c C_INT, --x C_INT, --y C_INT, --w C_INT, --x C_INT, --y C_INT, --w C_POINTER, --scl C_UINT --op }) public constant xGrSetDriver = define_c_func(mg,"+GrSetDriver",{C_POINTER},C_INT) public function GrSetDriver(object drvspec) return c_func(xGrSetDriver,{drvspec}) end function public constant xGrSetDriverExt = define_c_func(mg,"+GrSetDriverExt",{C_POINTER,C_POINTER},C_INT) public function GrSetDriverExt(object drvspec,object drvopt) return c_func(xGrSetDriverExt,{drvspec,drvopt}) end function public constant xGrSetMode = define_c_func(mg,"+GrSetMode",{C_INT,C_POINTER},C_INT) public function GrSetMode(GrGraphicsMode which,object x) return c_func(xGrSetMode,{which,x}) end function
[https://www.fgrim.com/mgrx/mgrxpm.htm#hello] - C Min example
--Minimal example loosely converted from the C example include std/ffi.e include mgrx.e include mgrxkeys.e atom ev = allocate_struct(GrEvent) -- Initialize graphics mode and events GrSetMode(GR_default_graphics, NULL) GrEventInit() -- Draw outer and inner borders GrBox(0, 0, GrMaxX(), GrMaxY(), GrWhite()) GrBox(2, 2, GrMaxX() - 2, GrMaxY() - 2, GrWhite()) -- Wait for user interaction (key press or mouse click) GrEventWaitKeyOrClick(ev) -- Clean up and exit GrEventUnInit()
A window shows up and you close out of it, but the box dimensions and drawing looks off.
I'm able to build the library and examples without much fuss under WSL (Linux subsystem for Windows)

