require 'gl3'

A=: noun define
pc a closeok;
menupop "&Help";
menu help "&Help" "" "" "";
menupopz;
xywh 0 0 100 100;cc g isigraph ws_clipchildren ws_clipsiblings rightmove bottommove;
pas 0 0;
rem form end;
)

a_run=: verb define
wd A
glaRC''
Z =: 0
wd 'pshow;ptop'
)

a_g_char =: verb define
k=.0{sysdata
Z =: 2 <. Z + 0.1*'i'=k
Z =: _2 >. Z - 0.1*'o'=k
glpaintx''
)

a_g_size=:verb define
glViewport 0 0,glqwh''
glMatrixMode GL_PROJECTION
glLoadIdentity''
glOrtho _6 6 _6 6 _6 6
)

a_g_paint =: verb define
fog''

glMatrixMode GL_MODEL_VIEW
glLoadIdentity ''
glTranslate 0 0 , Z

sphere''
glaSwapBuffers''
)

fog=: verb define
glMatrixMode GL_MODELVIEW
glLoadIdentity''
glEnable GL_DEPTH_TEST
glDepthFunc GL_LEQUAL
glLight GL_LIGHT0, GL_POSITION, 0 3 3 0
glLightModel GL_LIGHT_MODEL_LOCAL_VIEWER, 0
glFrontFace GL_CW
glEnable GL_LIGHTING
glEnable GL_LIGHT0
glEnable GL_AUTO_NORMAL
glEnable GL_NORMALIZE
glEnable GL_FOG
glFog GL_FOG_MODE,GL_EXP
glFog GL_FOG_COLOR,0.5 0.5 0.5 1
glHint GL_FOG_HINT, GL_DONT_CARE
glClearColor 0.5 0.5 0.5 1
glClear GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT

glEnable GL_AUTO_NORMAL
glEnable GL_NORMALIZE
glEnable GL_FOG
glFog GL_FOG_MODE,GL_EXP
glFog GL_FOG_COLOR,0.5 0.5 0.5 1
glHint GL_FOG_HINT, GL_DONT_CARE
glClearColor 0.5 0.5 0.5 1
)

sphere=: verb define
obj=.gluNewQuadric''
glMaterial GL_FRONT,GL_AMBIENT, 0.1745 0.01175 0.01175 0
glMaterial GL_FRONT,GL_DIFFUSE, 0.61424 0.04136 0.04136 0
glMaterial GL_FRONT,GL_SPECULAR, 0.727811 0.626959 0.626959 0
glMaterial GL_FRONT,GL_SHININESS, (0.6*128), 0 0 0
gluQuadricCallback obj,GLU_ERROR
gluQuadricNormals obj,GLU_SMOOTH
gluQuadricDrawStyle obj,GLU_FILL
gluSphere obj,2 32 32
gluDeleteQuadric obj
)

a_help_button=: verb define
wd'mb OpenGL *Press i o to move in and out of the fog.'
wd 'setfocus g'
)

a_run''
