To close the loop as to why I asked this question I have attached the graphics 
program. It is simple. It uses the windows driver in J and the isigraph and gl2 
to create a window using the toucan.bmp bitmap that comes with J as the 
background. It starts displaying a single panel and when you resize the window 
it creates the appropriate panels of the bitmap to fill the new size of the 
window.

Thanks for the help.

Tom McGuire

NB. JQtWin - window driver usage
NB. get a bitmap and display as a background to a window

NB. the following sources were helpful to putting this code together:
NB. Bill Lam's answer on the Jprogramming forum (Displaying a PNG...):
NB. http://www.jsoftware.com/pipermail/programming/2018-April/050898.html
NB. https://code.jsoftware.com/wiki/User:Raul_Miller/OpenGL/Page2
NB. https://code.jsoftware.com/wiki/Guides/Window_Driver/Animation/Animated_JGL2
NB. 

   require 'gl2'
   coinsert 'jgl2'

NB. panelize - Make panels out of a bitmap
NB. Raul Miller's solution
NB. (,seed){~($seed)#.($seed)|"1 ($target)#:i.$target
NB.   panelize1 =: {{(,y){~($y)#.($y)|"1 (x)#:i.x}}
NB. 
NB. Elijah Stone's solution
NB. panelize2 =: {{(0{x)$(1{x)$"1 y}}
NB. 
NB. I used panelize2 that I put into tacit form
panelize =: (0 {  [) $ ] $"1~ 1 {  [

NB. runmywin - set up and start the window that has a toucan background
runmywin =: 3 : 0
   b =: readimg_jqtide_ jpath '~addons/graphics/bmp/toucan.bmp'
   wd 'pc mywin;pn ToucanWin'
   wd 'cc g isidraw'
   
   NB. this sets the minimum window width and length
   NB. the window can not be resized below this minimum
   wd 'set g minwh ', ":(|.$b)

   NB. pshow window driver call will send out a resize event
   NB. the rest of the code can be placed in the resize callback
   wd 'pshow'
)

NB. minimal cleanup that needs to be done so far
cleanupmywin =: 3 : 0
wd 'pclose'
wd 'reset'
)

NB. mywin_close - parent close callback name
mywin_close =: cleanupmywin

NB. Child window callbacks
mywin_g_initialize=: 3 : 0
NB. load extensions, query glGetString, compile shader, setting up buffers, 
etc...
NB. since different versions of GLSL are incompatible with each other,
NB. it needs to query the version of GLSL here and execute different codes.
)

NB. resize callback
NB. by putting the panelize code here when ever a resize event
NB. is created by the window system the bitmap is expanded or 
NB. contracted to fill the background appropriately
mywin_g_resize=: 3 : 0
NB. size of widget changed
'w h' =. ". wd 'get g wh'

c =: (h,w) panelize b
   glsel 'g'
0
   glpixels 0 0, (|. $c), ,c
0
   wd 'pshow'
)

mywin_g_paint=: 3 : 0
NB. OpenGL stuff here
NB. draw on OpenGL context
NB.
NB. additional overlay:
NB. use gl2 commands to draw on top of OpenGL surface such as text
NB. these gl2 commands for OpenGL overlay are similar to regular gl2 commands
NB. but with prefix gl_ instead of gl, eg
NB. gl_clear, gl_text
NB. GL_DEPTH_TEST must be disabled for overlay otherwise invisible
)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to