The glAlphaFunc function enables your application to set the alpha test function.
void glAlphaFunc( GLenum func, GLclampf ref );
- The alpha comparison function. The following are the accepted symbolic constants and their meanings.
Symbolic constant Meaning GL_NEVER Never passes. GL_LESS Passes if the incoming alpha value is less than the reference value. GL_EQUAL Passes if the incoming alpha value is equal to the reference value. GL_LEQUAL Passes if the incoming alpha value is less than or equal to the reference value. GL_GREATER Passes if the incoming alpha value is greater than the reference value. GL_NOTEQUAL Passes if the incoming alpha value is not equal to the reference value. GL_GEQUAL Passes if the incoming alpha value is greater than or equal to the reference value. GL_ALWAYS Always passes. This is the default.
- The reference value to which incoming alpha values are compared. This value is clamped to the range 0 through 1, where 0 represents the lowest possible alpha value and 1 the highest possible value. The default reference is 0.
The alpha test discards fragments depending on the outcome of a comparison between the incoming fragments' alpha values and a constant reference value. The glAlphaFunc function specifies the reference and comparison function. The comparison is performed only if alpha testing is enabled. (For more information on GL_ALPHA_TEST, see glEnable.)
The func and ref parameters specify the conditions under which the pixel is drawn. The incoming alpha value is compared to ref using the function specified by func. If the comparison passes, the incoming fragment is drawn, conditional on subsequent stencil and depth-buffer tests. If the comparison fails, no change is made to the framebuffer at that pixel location.
The glAlphaFunc function operates on all pixel writes, including those resulting from the scan conversion of points, lines, polygons, and bitmaps, and from pixel draw and copy operations. The glAlphaFunc function does not affect screen clear operations.
Alpha testing is done only in RGBA mode.
The following functions retrieve information related to the glAlphaFunc function:
glGet with argument GL_ALPHA_TEST_FUNC
glGet with argument GL_ALPHA_TEST_REF
glIsEnabled with argument GL_ALPHA_TEST
The following are the error codes generated and their conditions.
|GL_INVALID_ENUM||func was not an accepted value.|
|GL_INVALID_OPERATION||glAlphaFunc was called between a call to glBegin and the corresponding call to glEnd.|
Windows NT/2000: Requires Windows NT 3.5 or later.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in Gl.h.
Library: Use Opengl32.lib.