The glAlphaFunc function specifies the alpha test function.
void glAlphaFunc(
GLenum func,
GLclampf ref
);
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 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 frame buffer 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.
Error Code | Condition |
---|---|
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: Use version 3.5 and later.
Windows: Use Windows 95 and later.
Windows CE: Unsupported.
Header: Declared in gl.h.
Import Library: Link with opengl32.lib.
glBegin, glBlendFunc, glClear, glDepthFunc, glEnable, glEnd, glGet, glIsEnabled, glStencilFunc