glLogicOp function

The glLogicOp function specifies a logical pixel operation for color index rendering.

Syntax

void WINAPI glLogicOp(
   GLenum opcode
);

Parameters

opcode

A symbolic constant that selects a logical operation. The following symbols are accepted where s equals the value of the source bit and d is the value of the destination bit.

Value Meaning
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

Return value

This function does not return a value.

Error codes

The following error codes can be retrieved by the glGetError function.

Name Meaning
GL_INVALID_ENUM
opcode was not an accepted value.
GL_INVALID_OPERATION
The function was called between a call to glBegin and the corresponding call to glEnd.

Remarks

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 framebuffer. 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 framebuffer. 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

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Gl.h
Library
Opengl32.lib
DLL
Opengl32.dll

See also

glAlphaFunc

glBegin

glBlendFunc

glDrawBuffer

glEnable

glEnd

glIsEnabled

glStencilOp