The jzopenglutil.ijs script is very useful but I
have been unable to find or produce an example which makes
effective use of call lists. By effective use I mean that a
call list (actually, more than one, too) can be created only
one initial time and then used as needed in the verb paint.
In contrast, the opengl Lab demonstrates this effectively in
its use of the *conditionally executed* verb g_draw_init
taken from the script ogl_cubes.ijs shown next. (But I have
not been successful in combining the Lab example with the
Demo examples.)
g_draw_init=: 3 : 0
drawbox '' NB. create list that draws a box
glViewport 0 0,y
glMatrixMode GL_PROJECTION
glLoadIdentity''
gluPerspective 30, (%/y),1 10
)
ogl_cubes.ijs executes g_draw_init only
conditionally in gl3lab_g_paint as shown next.
gl3lab_g_paint=: 3 : 0
smoutput 'paint'
if. rc__ogl'' do. g_draw_init wh__ogl end.
g_draw''
show__ogl''
)
ogl_cubes.ijs accomplishes this feat by NOT calling
paint in gl3lab_run, while all the jzopenglutil examples
built around glviews.ijs DO call paint from opengl_run.
opengl_run=: 3 : 0
wd OPENGL
ogl=: ''conew'jzopengl'
opengl_g_paint''
wd'pshow;'
)
The opengl Lab examples seem to get around this
problem by including the verb gl3lab in the PREPARE section
of opengl.ijt as shown next. So, in the Lab, the verb gl3lab
calls paint the first time, not the verb gl3lab_run.
gl3lab=: 3 : 0
if. 1<+/(<'gl3lab')=<;._2 wd'qp' do.
while. +/(<'gl3lab')=<;._2 wd'qp' do.
wd'psel gl3lab;pclose' NB. close all if more than 1
end.
end.
try.
wd'psel gl3lab;pshow;pactive'
free__ogl'' NB. force new rc
gl3lab_g_paint'' NB. new drawing
catch.
gl3lab_run''
end.
i.0 0
)
In contrast consider the script
j601/system/examples/graphics/opengl/demo/basic5.ijs which
contains the paint verb below, which creates the call list
CYLINDERS *every time* paint is executed (in drawcylinders).
paint=: 3 : 0
gsinit GS_LIGHT,GS_BLEND
drawcylinders ''
gsfini''
)
I have attempted to alter the paint verb in
basic5.ijs to *only conditionally* execute drawcylinders as
follows. But when I do so, the cylinders are all redrawn in
their original orientation even after I have used arrow keys
to reorient the graphics image.
glaIsList=: a.&[EMAIL PROTECTED]
paint=: 3 : 0
gsinit GS_LIGHT,GS_BLEND
if. -. glaIsList CYLINDERS do. drawcylinders '' end.
gsfini''
)
I would like to be shown an example of this
effective use of call lists in the context of
jzopenglutil.ijs such as in the script basic5.ijs.
Thank you.
(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm