NB. ogl12.ijs

dokey=: verb define
k=. 'xyz' = {. sysdata  NB. poll state of x y z keys
if. -. sysfocus -: ,'g' do. return. end.
R =: 360 | R + 2 * k
if. +/k do. glpaintx'' end.
)


BLUE=:  0 0 1
GREEN=: 0 1 0
RED=:   1 0 0

drawbox=:3 : 0
BOX=:1
p=. _1 ^ #: i.8
glNewList BOX , GL_COMPILE
 BLUE         polygon 0 1 3 2{p
 GREEN        polygon 0 1 5 4{p
 RED          polygon 0 2 6 4{p
 (RED+BLUE)   polygon 4 5 7 6{p
 (RED+GREEN)  polygon 1 3 7 5{p
 (BLUE+GREEN) polygon 2 3 7 6{p
glEndList ''
)

polygon=: 4 : 0
glColor 4{.x.,1
glBegin GL_POLYGON
 glVertex y.
glEnd ''
)

a_run=: 3 : 0
wd :: ] 'psel a;pclose'
wd A
glaRC ''
R =: 0 0 0
drawbox ''          NB. create list that draws a box
wd 'pshow;ptop'
)

a_g_char =: verb define
R =: 360 | R + 2 * 'xyz' = 0 { sysdata
glpaintx''
)

a_g_size=:3 : 0
wh=.glqwh''
glViewport 0 0,wh
glMatrixMode GL_PROJECTION
glLoadIdentity''
gluPerspective 60, (%/wh),1 10
)

a_g_paint =: verb define
if. -.IFJAVA do.
 a_g_size''
end.
glClearColor 1 1 1 0
glClear GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT
glEnable GL_DEPTH_TEST
glMatrixMode GL_MODELVIEW
glLoadIdentity''
glTranslate 2 0 _8
glRotate R ,. 3 3 $ 1 0 0 0
glCallList BOX
glMatrixMode GL_MODELVIEW
glLoadIdentity''
glTranslate _2 0 _8
glRotate R ,. 3 3 $ 1 0 0 0
glCallList BOX
glaSwapBuffers ''
)

A=: 0 : 0
pc a closeok;
xywh 0 0 100 100;cc g isigraph ws_clipchildren ws_clipsiblings rightmove bottommove;
pas 0 0;
rem form end;
)
