Scissor Test

From OpenGL.org
Jump to: navigation, search

The Scissor Test is a Per-Sample Processing operation that discards Fragments that fall outside of a certain rectangular portion of the screen.

To define the scissor box, use this function:

void glScissor(GLint x​, GLint y​, GLsizei width​, GLsizei height​);

The x​ and y​ is the window-space lower-left position of the scissor box, and width​ and height​ define the size of the rectangle.

Simply setting the rectangle is not enough. To actually discard fragments outside of this region, you must activate scissoring. This is done by enabling GL_SCISSOR_TEST​.

Scissor array

Viewport Arrays
Core in version 4.4
Core since version 4.1
Core ARB extension ARB_viewport_array

When multiple viewports are used, each viewport has its own separate scissor box. The glScissor above sets the scissor box for all viewports.

Each viewport has its own enable state for the scissor test, as set by glEnablei/Disablei. Using the non-indexed glEnable/Disable will enable or disable scissoring for all viewports.

To set the scissor box for a specific viewport, use one of these functions:

void glScissorIndexed(GLuint index​, GLint left​, GLint bottom​, GLsizei width​, GLsizei height​);

void glScissorIndexedv(GLuint index​, const GLint *v​);

index​ must be less than GL_MAX_VIEWPORTS​. The array version takes 4 integers, in the same order as the parameters for glScissorIndexed.

The scissor box for several viewports can be set with this function:

void glScissorArrayv(GLuint first​, GLsizei count​, const GLint *v​);

This sets each viewport's scissor box starting from first​ up to (but not including) first​ + count​. v​ is an array, where every 4 elements of the array are the scissor box for a single viewport. Therefore, v​ is expected to contain 4 * count​ elements.