Please run the attached standalone openGL script.
What I want and what I get are two different things. I would
like to understand how to get what I want which is the
following.
Want:
1 red turtle and 1 blue turtle
1 of the turtles has a green head and a magenta nose
1 of the turtles has a magenta head and a green nose
And I would like to understand why I am getting the
following.
Get:
1 red turtle and 1 blue turtle
BOTH of the turtles have a green head and a magenta nose
Three extra spheres in the upper center. I think 1 is green
and 2 are magenta, but I am color defective and no one is
here for me to ask.
If you see something different from what I get, then other
than the color defectiveness, there may be something screwy
about the Java or Mac I am using.
Thanx.
(B=) <----------my "sig"
Brian Schott
Atlanta, GA, USA
schott DOT bee are eye eh en AT gee em ae eye el DOT com
http://schott.selfip.net/~brian/NB. turtledebug.ijs
NB. standalone verseion
require 'opengl trig'
coinsert 'jgl3 jzopengl '
load 'trig'
turtle0 =: monad define
glPushMatrix ''
NB. glPushAttrib GL_CURRENT_COLOR
glEnable GL_NORMALIZE
glColor 1 0 0 1
glTranslate _1 0 0
glRotate ROTturtle
glScale SCALE * SIZE
glClipPlane GL_CLIP_PLANE0, 0 0 1 0
glEnable GL_CLIP_PLANE0
gluSphere LQuad, 1 30 30
glCallList LHead
glDisable GL_CLIP_PLANE0
NB. glPopAttrib ''
glPopMatrix ''
)
turtle1 =: monad define
glPushMatrix ''
NB. glPushAttrib GL_CURRENT_COLOR
glEnable GL_NORMALIZE
glColor 0 0 1 1
glTranslate 1 0 0
glRotate ROTturtle
glScale SCALE * SIZE
glClipPlane GL_CLIP_PLANE0, 0 0 1 0
glEnable GL_CLIP_PLANE0
gluSphere LQuad, 1 30 30
glCallList LHead
glDisable GL_CLIP_PLANE0
NB. glPopAttrib ''
glPopMatrix ''
)
turtlehead =: monad define
glPushMatrix ''
glPushAttrib GL_CURRENT_COLOR
glTranslate 0 1 0
glColor HCOLOR
gluSphere LQuad, TURTLE_HEAD_RELATIVE , 30 30
glColor NCOLOR
glCallList LNose
glPopAttrib ''
glPopMatrix ''
)
turtlenose =: monad define
glPushMatrix ''
glPushAttrib GL_CURRENT_COLOR
glTranslate 0 0.25 0
gluSphere LQuad, TURTLE_HEAD_RELATIVE , 30 30
glPopAttrib ''
glPopMatrix ''
)
ROTturtle =: 30 0 0 1
SIZE =: 0.2 NB. turtle body size relative to 1
SCALE =: 1 2 0.5 NB. turtle elliptical rescale
TURTLE_HEAD_RELATIVE =: 0.3 NB. head size relative to body
run =: verb define
gldefault''
glinit''
stdlistlight''
LQuad =: gluNewQuadric''
gluQuadricDrawStyle LQuad,GLU_FILL
gluQuadricNormals LQuad,GLU_SMOOTH
genlist 'LTurtle0 LTurtle1 LHead LNose'
NCOLOR =: 0 1 0 1
HCOLOR =: 1 0 1 1
turtlenose makelist LNose ''
turtlehead makelist LHead ''
turtle0 makelist LTurtle0''
HCOLOR =: 0 1 0 1
NCOLOR =: 1 0 1 1
turtlenose makelist LNose ''
turtlehead makelist LHead ''
turtle1 makelist LTurtle1''
glaSwapBuffers ''
glpaintx''
)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm