require 'gl3'

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

a_run=: verb define
wd A
glaRC''
MODE=: GL_EXP
sphere''
wd 'pshow;ptop'
)

a_g_char=: verb define
MODE=: (1 i.~'123'={.sysdata){GL_EXP,GL_EXP2,GL_LINEAR,MODE
glpaintx''
)

a_g_size=: verb define
glViewport 0 0,wh=. glqwh''
glMatrixMode GL_PROJECTION
glLoadIdentity''
wh=. \:~wh
glOrtho _2.5 2.5,(_2.5*%~/wh),(2.5*%~/wh),_10 10
)

a_g_paint=: verb define
glMatrixMode GL_MODELVIEW
glLoadIdentity''
glClearColor 0.5 0.5 0.5 1
glClear GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
fog''
3 : 'glCallList SPHERE[glTranslate y.[glLoadIdentity$0'"1] (i:2),._0.5,.->:i.5
glaSwapBuffers''
)

fog=: verb define
glEnable GL_DEPTH_TEST
glLight GL_LIGHT0, GL_POSITION, 0.5 0.5 3 0
glEnable GL_LIGHTING
glEnable GL_LIGHT0

glEnable GL_FOG
glFog GL_FOG_MODE, MODE
glFog GL_FOG_COLOR,0.5 0.5 0.5 1
glFog GL_FOG_DENSITY,0.35
glHint GL_FOG_HINT, GL_DONT_CARE
glFog GL_FOG_START, 1
glFog GL_FOG_END, 5
)

sphere=: verb define
obj=. gluNewQuadric''
glNewList (SPHERE=: glGenLists 1),GL_COMPILE
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,0.4 32 32
glEndList''
gluDeleteQuadric obj
)

a_help_button=: verb define
wd'mb OpenGL *Press 1, 2, and 3 to switch between fog functions.'
wd 'setfocus g'
)

a_run''
