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