Graphics Reference
In-Depth Information
for ( i = 0; i < NumTests; ++i )
{
glStencilFunc ( GL_EQUAL, stencilValues[i], 0xff );
glUniform4fv ( userData->colorLoc, 1, colors[i] );
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE,
indices[4] );
}
Depth Buffer Testing
The depth buffer is typically used for hidden-surface removal. It traditionally
keeps the distance value of the closest object to the viewpoint for each pixel
in the rendering surface, and for every new incoming fragment, compares
its distance from the viewpoint with the stored value. By default, if the
incoming fragment's depth value is less than the value stored in the depth
buffer (meaning it's closer to the viewer), the incoming fragment's depth
value replaces the values stored in the depth buffer, and then its color value
replaces the color value in the color buffer. This is the standard method for
depth buffering—and if that's what you would like to do, you simply need
to request a depth buffer when you create a window, and then enable the
depth test by calling glEnable with GL_DEPTH_TEST . If no depth buffer is
associated with the color buffer, the depth test always passes.
Of course, that's only one way to use the depth buffer. You can modify the
depth comparison operator by calling glDepthFunc .
void glDepthFunc (GLenum func )
specifies the depth value comparison function, which can be one
of GL_LESS , GL_GREATER , GL_LEQUAL , GL_GEQUAL ,
GL_EQUAL , GL_NOTEQUAL , GL_ALWAYS , or GL_NEVER
func
Blending
This section discusses blending pixel colors. Once a fragment passes all of
the enabled fragment tests, its color can be combined with the color that's
already present in the fragment's pixel location. Before the two colors are
combined, they're multiplied by a scaling factor and combined using the
specified blending operator. The blending equation is
C
=
f
C
op
f
C
final
source
source
destination
destination
 
 
 
Search WWH ::




Custom Search