I’m having a problem with a simple OpenGL program. There is
little GL code at all right now, just a framework for switching
between different “scenes” and a couple of test triangles. I’ve
zipped up the Python code and put it on my website
(http://davemikesell.net/code.zip), but essentially the GL calls
are happening in this order shown below. The first red triangle
appears as expected, but the 2nd blue one does not after the scene is changed (i.e. the screen is black).
I’m obviously doing something out of order, but I’m not sure what it
is. What am I overlooking?
Resize, initialization
glShadeModel(GL_SMOOTH)
glClearColor(0.0, 0.0, 0.0, 1.0)
glClearDepth(1.0)
glViewport(0, 0, WIDTH, HEIGHT)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(0.0, WIDTH, 0.0, HEIGHT)
glMatrixMode(GL_MODELVIEW)
Draw red triangle
glColor4f(1.0, 0.0, 0.0, 1.0)
glBegin(GL_TRIANGLES)
glVertex3f( 0.0, 1.0, 0.0)
glVertex3f(-1.0,-1.0, 0.0)
glVertex3f( 1.0,-1.0, 0.0)
glEnd()
Scene switches
Resize, initialization
glShadeModel(GL_SMOOTH)
glClearColor(0.0, 0.0, 0.0, 1.0)
glClearDepth(1.0)
glViewport(0, 0, WIDTH, HEIGHT)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(0.0, WIDTH, 0.0, HEIGHT)
glMatrixMode(GL_MODELVIEW)
Draw blue triangle
glColor4f(0.0, 0.0, 1.0, 1.0)
glBegin(GL_TRIANGLES)
glVertex3f( 0.0, 1.0, 0.0)
glVertex3f(-1.0,-1.0, 0.0)
glVertex3f( 1.0,-1.0, 0.0)
glEnd()