/ comp / gb.opengl / gl / alphafunc
Gl.AlphaFunc (gb.opengl)
Syntax

    STATIC SUB AlphaFunc ( Function AS Integer, Reference AS Float )

### Specify the alpha test function

#### Parameters

- Function specifies the alpha comparison function. Symbolic constants Gl.GL_NEVER, Gl.GL_LESS, Gl.GL_EQUAL, Gl.GL_LEQUAL, Gl.GL_GREATER, Gl.GL_NOTEQUAL, Gl.GL_GEQUAL, and Gl.GL_ALWAYS are accepted. The default function is Gl.GL_ALWAYS.

- Reference specifies the reference value that incoming alpha values are compared to. 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.

#### Description

The alpha test discards fragments depending on the outcome of a comparison between the incoming fragment's alpha value and a constant reference value. AlphaFunc specifies the reference and comparison function. The comparison is performed only if alpha testing is enabled. (See Gl.Enable and Gl.Disable of Gl.GL_ALPHA_TEST.)

Function and Reference specify the conditions under which the pixel is drawn. The incoming alpha value is compared to Reference using the function specified by Function. 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 comparison functions are as follows:

- Gl.GL_NEVER never passes.

- Gl.GL_LESS passes if the incoming alpha value is less than the reference value.

- Gl.GL_EQUAL passes if the incoming alpha value is equal to the reference value.

- Gl.GL_LEQUAL passes if the incoming alpha value is less than or equal to the reference value.

- Gl.GL_GREATER passes if the incoming alpha value is greater than the reference value.

- Gl.GL_NOTEQUAL passes if the incoming alpha value is not equal to the reference value.

- Gl.GL_GEQUAL passes if the incoming alpha value is greater than or equal to the reference value.

- Gl.GL_ALWAYS always passes.

AlphaFunc 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. AlphaFunc does not affect screen clear operations.

| Alpha testing is done only in RGBA mode.

#### Errors

Gl.GL_INVALID_ENUM is generated if Function is not an accepted value.
Gl.GL_INVALID_OPERATION is generated if AlphaFunc is called between a call to Gl.Begin and the corresponding call to Gl.End.

#### Associated Gets

Gl.GetAlphaTestFunc
Gl.GetAlphaTestRef
Gl.IsEnabled with argument Gl.GL_ALPHA_TEST

### See also

Gl.BlendFunc , Gl.Clear , Gl.DepthFunc , Gl.Enable , Gl.StencilFunc