Have you come up with a way to handle SDL events? I was able to read events but if I set up a polling loop I ran into problems with J not getting time for handling Its own user events. I made some attempts to use wd ‘msgs’ from the window driver but was unsuccessful.
Tom McGuire > On Nov 27, 2020, at 1:36 PM, emacstheviking <[email protected]> wrote: > > that took a few seconds to sink in but..yes, I see now. > > On Fri, 27 Nov 2020 at 16:46, bill lam <[email protected]> wrote: > >> Well done! >> >> Sometimes I found it easier to read if negative index are used, >> >> 'rw rh' =. _2 _1 dmva sdl_getrenderoutputsize appr;(_1);(_1) >> >> On Sat, Nov 28, 2020, 12:19 AM emacstheviking <[email protected]> wrote: >> >>> Final more J-like solution to my problem, thanks bill Iam for the >> nudge... >>> >>> dmva =: 4 : '''''&$ each (x{y)' >>> >>> This allows me to specify the actual array positions I want de-arrayed / >>> scalerised and feels much more natural in use as I can now specify any >>> number of positions and of course re-order things too. Probably the only >>> improvement now is the name! >>> >>> 'rw rh' =. 2 3 dmva sdl_getrenderoutputsize appr;(_1);(_1) >>> >>> I appreciate that ''$ is only producing scales because the first atom of >> my >>> array contains a scalar. I think. ! >>> Thanks all once again, >>> Sean. >>> >>> >>> On Fri, 27 Nov 2020 at 13:05, bill lam <[email protected]> wrote: >>> >>>> probably your width and height are not scalar but singleton array. you >>> can >>>> check them with monad $ . >>>> >>>> On Fri, Nov 27, 2020, 8:00 PM emacstheviking <[email protected]> >> wrote: >>>> >>>>> Given these working external function declarations: >>>>> >>>>> SDL_GetWindowSize n x *i *i >>>>> SDL_GetRendererOutputSize n x *i *i >>>>> SDL_CreateRGBSurface > x i i i i i i i i >>>>> >>>>> then these two calls: >>>>> >>>>> 'ww wh'=:2}.sdl_getwindowsize appw;(,_1);(,_1) >>>>> 'rw rh'=:2}.sdl_getrendereroutputsize appr;(,_1);(,_1) >>>>> >>>>> work and produce values of 1024 for ww and rw, and 768 for wh and rh >>>>> respectively, as expected. >>>>> However, when creating the rgb surface it raises a domain error and I >>>> have >>>>> been tearing my hair out to understand why. >>>>> I have posted the full code at the end of this plea for help and >>>>> enlightenment. >>>>> >>>>> args=.0;width;height;32;16bff0000;16bff00;16bff;16bff000000 >>>>> smoutput args >>>>> sfc=: sdl_creatergbsurface args >>>>> >>>>> cder'' >>>>> 6 1 >>>>> >>>>> yet calling it with literals or even the extracted 'y' value (a boxed >>>>> dimension): >>>>> args=.0;1024;768;32;16bff0000;16bff00;16bff;16bff000000. NB. works >>>>> args=.0;width;height;32;16bff0000;16bff00;16bff;16bff000000. NB. >> works >>>>> >>>>> I have used 3!:0 to examine the type, it is 4 (integer) in all cases >>>>> (ww,wh,rw,rh,width,height), ruling out those errors. >>>>> Thanks, >>>>> Sean. :| >>>>> >>>>> -- full code --- >>>>> >>>>> ugo =: 3 : 0 >>>>> NB. testing out domain errors around sdl_creatergbsurface... >>>>> args =. SCREEN_X_MAX;SCREEN_Y_MAX >>>>> scrw =. SCREEN_X_MAX >>>>> scrh =. SCREEN_Y_MAX >>>>> sdlprep scrw;scrh >>>>> cairoprep'' >>>>> urun'' >>>>> uend^:y '' >>>>> ) >>>>> >>>>> sdlprep =: 3 : 0 >>>>> 'width height'=. y >>>>> sdl_init SDL_INIT_EVERYTHING >>>>> appw=:sdl_createwindow 'test window';0;0 >>>>> ;width;height;SDL_WINDOW_SHOWN+SDL_WINDOW_ALLOW_HIGHDPI >>>>> appr=:sdl_createrenderer appw;_1 >>>>> ;SDL_RENDERER_ACCELERATED+SDL_RENDERER_PRESENTVSYNC >>>>> 'ww wh'=:2}.sdl_getwindowsize appw;(,_1);(,_1) >>>>> 'rw rh'=:2}.sdl_getrendereroutputsize appr;(,_1);(,_1) >>>>> cxm=: rw % ww >>>>> cym=: rh % wh >>>>> smoutput 'window: ', (":appw), 'renderer:', (":appr) >>>>> smoutput 'requested width:',(":width),' height:',(":height) >>>>> smoutput 'render width: ',(":rw),' height:',(":rh) >>>>> smoutput 'window width: ',(":ww),' height:',(":wh) >>>>> smoutput 'x/y multipliers:',(":cxm),'/',(":cym) >>>>> NB. This needs to be endian-aware at some point >>>>> smoutput (": (width = rw)) >>>>> args=.0;width;height;32;16bff0000;16bff00;16bff;16bff000000 >>>>> smoutput args >>>>> sfc=: sdl_creatergbsurface args >>>>> NB. Practice structures. PACKING!!! Show printable format name >>>>> pFormat=._3 ic memr (sfc+8),0,8 NB. sdl_surface->format >>>>> format=._2 ic memr pFormat,0,4 NB. sdl_surface->format->format >>>>> smoutput 'pixel format:',(psz sdl_getpixelformatname format) >>>>> EMPTY >>>>> ) >>>>> >> ---------------------------------------------------------------------- >>>>> For information about J forums see >> http://www.jsoftware.com/forums.htm >>>>> >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >>> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
