glReadPixels + GL_DEPTH_COMPONENT

Started by
1 comment, last by MButchers 22 years, 4 months ago
Hello there, im currently using glReadPixels with the depth component and its just killed my frame rate ( its down from 170''s to 120''s-150''s FPS ) after just adding this single call. I assume opengl is flushing the output before it completes this call as im only retrieving one pixel value. (luckily i only need to call this procedure once every frame so i can probably live with it) Is there a better way to get the value from the depth buffer. many thanks Mark
Advertisement
As far as I''ve tried, with almost every API and card, reading the depth buffer is performance killing, and honestly doesn''t work any better with OpenGL sluggish readPixels... I don''t know what r you using this depth for (perhaps picking?), but try to find a workaround...

(BTW, don''t assume that OpenGL have "finished" the output until you manually do glFlush(), it may not work withg some implementations)

Regards

Matt
Matt
A call to glReadPixels will stall the whole rendering pipeline, and I don''t recomend reading from OpenGL (and that includes glGet-commands aswell) unless you HAVE to.

quote:
(BTW, don''t assume that OpenGL have "finished" the output until you manually do glFlush(), it may not work withg some implementations)


All OpenGL commands that return something is guaranteed to return the value they "should" return. Drawing a huge model, and immediately reading a pixel, will guarantee that the model is drawn properly before the actual work is done by glReadPixels. This is the reason why all get-like commands is a performance killer, they have to wait for the pipeline to finish what it has started.

And don''t call glFinish/glFlush if you have to. The only places where they are actually needed is in client-server rendering, and in single buffered rendering.

This topic is closed to new replies.

Advertisement