PDA

View Full Version : glDrawBuffer( GL_NONE ) expected behaviour



grumpus
12-19-2002, 04:48 PM
Hi All,

I'm getting different outcomes of the same OpenGL code on two different video cards and hoped to find out other people's experiences of using glDrawBuffer( GL_NONE ).

PseudoCode of what I am doing:

drawTerrain();
if( !BaseVisible )
glDrawBuffer( GL_NONE );
drawBase();
if( !BaseVisible )
glDrawBuffer( GL_BACK );
drawClouds();

To explain this, I am drawing puffy clouds (not just for effect, they represent some data) using a number of triangles placed in front of each other using blending which gives a nice puffy cloud look. Unfortunately the triangle bottom coords are at the level of the lowest point of the terrain and therefore some clouds get drawn underneath if the terrain coords of certain points are higher than where the clouds are generated. The base is something I use to display height data on and makes the terrain look like a block. The base can be turned on or off at runtime to help with viewing the terrain.

On a GeForce 2 MX 400 card with BaseVisible = false I don't see the clouds underneath the terrain as the DrawBuffer NONE seems to
hide the clouds behind the now 'invisible' base. However on a Matrox G400, the base is mostly visible in that most but not all of its components are still drawn. I broke the code down in to a simple example and found that, DrawBuffer NONE just draws the first shape after its call as all black, not invisible and then draws the second and third etc shapes with normal colour, as if DrawBuffer NONE hadn't been called. I am using the 5.12.01.1860 driver which is recent if not the latest.

I appreciate that I may have to go a different path to hide the clouds but hoped to find out if others have had a similar problem with this function on various vid cards.

Thanks for any assistance.

pbrown
12-19-2002, 05:08 PM
DrawBuffer(NONE) is supposed to send all color buffer writes to the bit bucket. Anything you render will still update the Z and stencil buffers, when the appropriate tests are enabled.

One other possibility to try is to call:

glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

This will disable writes to all components. In some cases, calling glColorMask instead of glDrawBuffer may be faster.

grumpus
12-19-2002, 05:22 PM
Many thanks pbrown, you're a champion! Using glColorMask instead of glDrawBuffer worked the trick.

Cheers.