[visionegg] Re: GL state responsibility (warning: may contain theory)

  • From: Tony Arkles <tony@xxxxxxxxx>
  • To: visionegg@xxxxxxxxxxxxx
  • Date: Wed, 13 Jul 2005 15:41:20 -0600

Bertrand Guay-Paquet wrote:

You are right about your assessment that stimuli positioning should be done this way:
-glPushMatrix()
-glTranslatef(position_of_stimulus)
-stimulus.draw()
-glPopMatrix()


This is what we have been thought in computer engineering classes at any rate. The positioning should be done in a hierarchical way when drawing multipart scenes. This is not currently the case with every stimulus calling glLoadIdentity().

Just wanted to contribute a little to the discussion.

You mention that you use the GL_PROJECTION matrix to point the camera? I'd be curious to know how you do it!

Right now if you look at the Projection class (in Core.py), it illustrates what is being done. Essentially there are a series of functions (translate, rotate, look_at, etc...) that all just act on the GL_PROJECTION matrix. Here's an example:


def translate(self,x,y,z):
"""Compose a translation and set the OpenGL projection matrix."""
gl.glMatrixMode(gl.GL_PROJECTION) # Set OpenGL matrix state to modify the projection matrix
gl.glLoadMatrixf(self.parameters.matrix) # Need PyOpenGL >= 2.0
gl.glTranslatef(x,y,z)
self.parameters.matrix = gl.glGetFloatv(gl.GL_PROJECTION_MATRIX)


From what I understand, it's recommended (by the OpenGL people) that all this be done on the GL_MODELVIEW matrix instead of the GL_PROJECTION matrix for all of the stimuli. I think that as long as we don't have too complex of a scene (to overflow the glPushMatrix() stack), the hierarchy method would be a lot more flexible.

Tony

======================================
The Vision Egg mailing list
Archives: //www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: