The glLogicOp function specifies a logical pixel operation for color index rendering.
void glLogicOp(
GLenum opcode
);
Opcode | Resulting Value |
---|---|
GL_CLEAR | 0 |
GL_SET | 1 |
GL_COPY | s |
GL_COPY_INVERTED | !s |
GL_NOOP | d |
GL_INVERT | !d |
GL_AND | s & d |
GL_NAND | !(s & d) |
GL_OR | s | d |
GL_NOR | !(s | d) |
GL_XOR | s ^ d |
GL_EQUIV | !(s ^ d) |
GL_AND_REVERSE | s & !d |
GL_AND_INVERTED | !s & d |
GL_OR_REVERSE | s | !d |
GL_OR_INVERTED | !s | d |
The glLogicOp function specifies a logical operation that, when enabled, is applied between the incoming color index and the color index at the corresponding location in the frame buffer. The logical operation is enabled or disabled with glEnable and glDisable using the symbolic constant GL_LOGIC_OP.
The opcode parameter is a symbolic constant chosen from the list below. In the explanation of the logical operations, s represents the incoming color index and d represents the index in the frame buffer. Standard C-language operators are used. As these bitwise operators suggest, the logical operation is applied independently to each bit pair of the source and destination indexes.
Logical pixel operations are not applied to RGBA color buffers.
When more than one color-index buffer is enabled for drawing, logical operations are done separately for each enabled buffer, using the contents of that buffer for the destination index (see glDrawBuffer).
The opcode parameter must be one of the 16 accepted values. Other values result in an error.
The following functions retrieve information related to glLogicOp:
glGet with argument GL_LOGIC_OP_MODE
glIsEnabled with argument GL_LOGIC_OP
The following are the error codes generated and their conditions.
Error Code | Condition |
---|---|
GL_INVALID_ENUM | opcode was not an accepted value. |
GL_INVALID_OPERATION | glLogicOp 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.
glAlphaFunc, glBegin, glBlendFunc, glDrawBuffer, glEnable, glEnd, glIsEnabled, glStencilOp