Advertisement
emacstheviking

Untitled

Nov 26th, 2020 (edited)
1,913
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
J 1.89 KB | None | 0 0
  1. Foreign declaration:   SDL_CreateRGBSurface > x i i i i i i i i
  2.  
  3. sdlprep =: 3 : 0
  4. 'width height'=. y
  5.   sdl_init SDL_INIT_EVERYTHING
  6.   appw=:sdl_createwindow 'test window';0;0;width;height;SDL_WINDOW_SHOWN+SDL_WINDOW_ALLOW_HIGHDPI
  7.   appr=:sdl_createrenderer appw;_1;SDL_RENDERER_ACCELERATED+SDL_RENDERER_PRESENTVSYNC
  8.   'ww wh'=:2}.sdl_getwindowsize appw;(,_1);(,_1)
  9.   'rw rh'=:2}.sdl_getrendereroutputsize appr;(,_1);(,_1)
  10.   NB. cxm=: rw % ww
  11.   NB. cym=: rh % wh
  12.   smoutput 'window:', (":appw), 'renderer:', (":appr)
  13.   smoutput 'render width:',(":rw),' height:',(":rh)
  14.   smoutput 'window width:',(":ww),' height:',(":wh)
  15.   NB. This needs to be endian-aware at some point
  16.   args=.0;rw;rh;32;16bff0000;16bff00;16bff;16bff000000
  17.   smoutput args
  18.   sfc=: sdl_creatergbsurface args
  19.   NB. Practice structures. PACKING!!! Show printable format name
  20.   pFormat=._3 ic memr (sfc+8),0,8 NB. sdl_surface->format
  21.   format=._2 ic memr pFormat,0,4  NB. sdl_surface->format->format
  22.   smoutput 'pixel format:',(psz sdl_getpixelformatname format)
  23.   EMPTY
  24. )
  25.  
  26. output when running...
  27.  
  28. window:140547920885040renderer:140547920929408
  29. render width:1024 height:768
  30. window width:1024 height:768
  31. ┌─┬────┬───┬──┬────────┬─────┬───┬──────────┐
  32. 010247683216711680652802554278190080
  33. └─┴────┴───┴──┴────────┴─────┴───┴──────────┘
  34. |domain error: sdl_creatergbsurface
  35. |   sfc=:    sdl_creatergbsurface args
  36.    cder''
  37. 6 1
  38.  
  39. The arg in question is the 1024, in a variable called rw, renderer width, but if I call by hand it works i.e. using numbers to set the surface dimensions:
  40.  
  41.    sdl_creatergbsurface 0;1024;768;32;16711680;65280;255;4278190080
  42. 140547918948464
  43.  
  44. Not sure why it won't take the value of the 'rh' variable?!?!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement