Skip to main content
gamedev.net
🔒 Locked

glReadPixels()

Started by LarrxX 0 replies 350+ views
Original Post
LarrxX
LarrxX
Are there any special OGL variables to set to be able to use glReadPixels? The only thing I can think about (for using it the way I am) is to enable depth testing, when I use the following code: Glfloat z = -10.0; glReadPixels( X, _viewport[3]-Y, 1, 1,GL_DEPTH_COMPONENT, GL_FLOAT, (GLvoid*)(&Z) ); I ALWAYS get either 1 or -10.0 in Z, whatever the X and Y window coordinates. In case there''s no obvious thing that should be done before using glReadPixels(), here''s exactly what I''m doing: -First I select an area of the viewport, you know like when u click the left mouse button and drag it to form a square and select everything inside. -I use this square to create a gluPickMatrix before using the gluProjection to set up the GL_PROJECTION matrix. -Then in GL_MODELVIEW I apply the reverse camera transformations. -I switch to feedback mode. -I render the scene into the feedback buffer. -I parse the buffer and get the X and Y coordinates of the vertices which I pass to glReadPixels to get the Z in the depth buffer. My question is, because of the use of gluPickMatrix, do I have to manually change the Raster Position to match the viewport area selected? I tried glRasterPos(0,0) and glRasterPos( X-(width/2), Y-(height/2) ), and both gave the same result. Perhaps there''s something I''m missing entirely... Thanx for the help

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.