Thread: [PyOpenGL-Users] gluUnProject() and glReadPixels()
Brought to you by:
mcfletch
From: Ian K. <Ian...@rm...> - 2004-10-19 13:28:29
|
I am using a glFrustum projection and am trying to convert mouse event (pixel) coordinates to model coordinates. I am having problems getting the window Z coordinate. As I understand, the Z coord is the depth buffer value expressed as a GLdouble with a range of 0-1. 0 being the near clip plane, and 1 being the far clip plane. My model view is a single textured surface in the x-y plane at z = 0 (object coord) - a 2d map. I have tried to used glReadPixels to get the win Z coord - but I can't get this function to return a GLDouble, hence gluUnProject doesn't like it. Looking at the glReadPixels manpages there is a glReadPixelsd() - but pyhton doesn't like this too much. z = glReadPixels(self.GetParent().xclick,300-self.GetParent().yclick, 1, 1, GL_DEPTH_COMPONENT, ???) worldcoord = gluUnProject(self.GetParent().xclick,300-self.GetParent().yclick,z,model,projection,viewport) I have looked at OpenGLContext briefly - would rather not use if my problem cam be solved without this module, but open to suggestions at this point! Thanks Ian |