I render a scene which may consist of up to 50 million triangles, so the rendering may take a while. Upon that rendered scene, I want to do some interactive “drawing”, f. ex. the user moves his mouse over the scene and additional things like a polyline will be rendered additionally onto the basic scene.
Since I want to avoid to re-render the large scene each time the user moves his mouse, I thought of rendering the basic scene first, storing the depth and color buffer, and on each mouse motion, copy these buffers back and then do the additional drawing commands.
The software must work on several cards, so I cannot use hardware-dependant code.
Do you think that using glReadPixels/glDrawPixels is the best way or are there better alternatives?
glReadPixels/glDrawPixels works fine for the color-buffer, but when I try to restore the depth buffer, I have problems; glDrawPixels seems to draw into the color buffer even when GL_DEPTH_COMPONENT is used.
Any hints how I can save and restore the depthbuffer?
DrawPixels always draws fragment groups (color/depth/stencil). It is up to you to mask off the parts you don’t want, with Disable for depth/stencil and ColorMask for color.