PDA

View Full Version : Simple problem



starman
08-03-2007, 09:43 AM
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()

Lindley
08-03-2007, 10:36 AM
Try displaying the second scene first. If it works, then your problem is probably state-related---you certain you got all your glLoadIdentity() calls in there?

If not, then there may be another problem.

starman
08-03-2007, 10:52 AM
Thanks - I did that before retiring last night, and the second scene displayed. Looks like I need to get my Eclipse/PyDev plugin working and step through it in the debugger.

Jedimaster
09-04-2007, 10:21 PM
glMatrixMode(GL_PROJECTION)
glLoadIdentity()

Hey, What's This ?! :cool: