On 24/11/10 16:10, Will wrote:
Hello, I am trying to mix 2d and 3d in opengl in pyglet, i.e. draw a
3d scene then switch to orthographic projection and draw stuff over
the top. I draw the 3d stuff, push the projection matrix to the
stack,  do a glOrtho projection matrix, draw the 2d stuff, then pop
the previous matrix off the stack.
The 3d stuff draws fine but for some reason the 2d part isn't drawing
at all, even on its own.
Here's the code:
#snip#
     def set2d(self):

         glDisable(GL_DEPTH_TEST)
         # store the projection matrix to restore later
         glMatrixMode(GL_PROJECTION)
         glPushMatrix()

         # load orthographic projection matrix
         glLoadIdentity()

         far = 8192
"far" is positive so your clipping points are at the camera and 8192 behind it.
         glOrtho(-self.width / 2., self.width / 2., -self.height / 2.,
self.height / 2., 0, far)

         # reset modelview
         glMatrixMode(GL_MODELVIEW)
         glLoadIdentity()

         #glClear(GL_COLOR_BUFFER_BIT)



     def unSet2d(self):

         # load back the projection matrix saved before
         glMatrixMode(GL_PROJECTION)
         glPopMatrix()

     def draw2d(self):
         z=-6
         n=100
         glTranslatef(0, 0.0, -z)


         glBegin(GL_TRIANGLES)
         glVertex3f(0.0, n, 0.0)
         glVertex3f(-n, -n, 0)
         glVertex3f(n, -n, 0)
         glEnd()

You then translate forward 6, ie past the near clipping point and draw your triangle.

HTH.

--
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to