require 'gl3'

A=: noun define
pc a closeok;
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''
SPHERE =: 2
sphere ''
wd 'pshow;ptop'
)

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

a_g_paint =: verb define
glClearColor 0 0 0 0
glClear GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT
glEnable GL_DEPTH_TEST
glMatrixMode GL_MODELVIEW
glLoadIdentity''
glTranslate 0 0 _8
light''
glCallList SPHERE
glaSwapBuffers ''
)

sphere=: verb define
obj=.gluNewQuadric''
Q =: obj
glNewList SPHERE,GL_COMPILE
 gluQuadricNormals obj,GLU_SMOOTH
 gluQuadricDrawStyle obj,GLU_FILL
 gluSphere obj,1.5 32 32
glEndList''
gluDeleteQuadric obj
)

light=: verb define
glLight GL_LIGHT0, GL_AMBIENT, 0.1 0.1 0.1 1
glLight GL_LIGHT0, GL_DIFFUSE, 0.7 0.7 0.7 1
glLight GL_LIGHT0,GL_SPECULAR, 0.0 0.0 0.0 1
glEnable GL_LIGHTING
glEnable GL_LIGHT0
glMaterial GL_FRONT,GL_AMBIENT_AND_DIFFUSE, 1 0 0 1
)

a_run''
