Difference between revisions of "Scissor Test"

From OpenGL Wiki
Jump to navigation Jump to search
m (→‎Scissor array: formatting)
(Which operations are affected.)
Line 33: Line 33:
  
 
This sets each viewport's scissor box starting from {{param|first}} up to (but not including) {{param|first}} + {{param|count}}. {{param|v}} is an array, where every 4 elements of the array are the scissor box for a single viewport. Therefore, {{param|v}} is expected to contain 4 * {{param|count}} elements.
 
This sets each viewport's scissor box starting from {{param|first}} up to (but not including) {{param|first}} + {{param|count}}. {{param|v}} is an array, where every 4 elements of the array are the scissor box for a single viewport. Therefore, {{param|v}} is expected to contain 4 * {{param|count}} elements.
 +
 +
== Affected commands ==
 +
 +
The scissor test affects all [[Rendering Command]]s that write values to the current draw [[Framebuffer]]. [[Compute#Dispatch|Compute shader dispatches]] are rendering commands, but they do not write to the framebuffer. Even if they write to an image that happens to be within a framebuffer, they are not considered to be writing to the framebuffer.
  
 
[[Category:General OpenGL]]
 
[[Category:General OpenGL]]
 
[[Category:Sample Writing]]
 
[[Category:Sample Writing]]

Revision as of 03:42, 17 January 2015

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

Affected commands

The scissor test affects all Rendering Commands that write values to the current draw Framebuffer. Compute shader dispatches are rendering commands, but they do not write to the framebuffer. Even if they write to an image that happens to be within a framebuffer, they are not considered to be writing to the framebuffer.