I have been experiencing an odd result when rendering with GL_COLOR_LOGIC_OP enabled.
The problem is as follows:
First I render a fairly large terrain surface in 2d. Once the surface has been drawn, I want to be able to draw a few simple lines on top of the surface without having to re-draw the surface. Using overlay planes was not an option, so I am using the following bit of code to draw the lines:
This works as expected (the lines are visible on the surface ) except when I swap between the front and back frame buffers.
I expected the lines to be drawn into the front frame buffer, thus requiring an eventual re-draw of the surface to clear those lines from that buffer. However if I swap the buffers twice, the line will no longer be visible. I do not understand why the front buffer is not modified by the line drawing. Any ideas?
I think you want to use polygon offset - I’m doing the exact same thing you are, and it works for me:
First, draw your lines as you would normally.
Next:
glEnable(GL_POLYGON_OFFSET);
glPolygonOffset(1.0,1.0); // example values
// Draw your filled polys as normal.
glDisable(GL_POLYGON_OFFSET);
Some notes from my own testing: This works best when you have a lot of resolution in your Z-buffer - that is, make sure your near plane is as far away from the camera as possible and your far plane is as close to it as possible.
Good point Matt, there is actually no need to use GL_COPY, I just happened to use a bad example in the code snippet. I have the same result no matter what logic op is used. Originaly, I was using GL_XOR in order to clear the lines without re-drawing the main surface. This worked fine, however I was trying to do a similar thing but with the ability to specify specific colors for the lines. It was at this point that I noticed that any drawing I do with GL_COLOR_LOGIC_OP enabled will be erased after the buffer swaps. This enables me to do what I want, however I do not understand why.
This works as expected (the lines are visible on the surface ) except when I swap between the front and back frame buffers.
I expected the lines to be drawn into the front frame buffer, thus requiring an eventual re-draw of the surface to clear those lines from that buffer. However if I swap the buffers twice, the line will no longer be visible. I do not understand why the front buffer is not modified by the line drawing. Any ideas?
<<
Very simple, the swap in your currently selected pixelformat does not exchange the front and back buffers, but copies the back buffer to the front buffer.
Before swap:
Front: FF
Back : BB
After swap:
Front: BB
Back : BB (or undefined, depending on swap method if not PFD_SWAP_COPY)
Now your lines are gone.
[This message has been edited by Relic (edited 01-29-2001).]