gl_ViewportIndex

From OpenGL Reference
Jump to navigation Jump to search

Contains the index of the viewport to be used in viewport transformation and scissoring.

Declaration[edit]

Description[edit]

In the geometry language,gl_ViewportIndexis used to specify the index of the viewport to which the next primitive emitted from the shader should be drawn. Primitives generated by the geometry shader will undergo viewport transformation and scissor testing using the viewport transformation and scissor rectangle selected by the value ofgl_ViewportIndex. The viewport index used will come from one of the vertices in the primitive being shaded. However, which vertex the viewport index comes from is implementation-defined, and so it is recommended to use the same viewport index for all vertices of a primitive. If a geometry shader does not assign a value togl_ViewportIndex, viewport transform and scissor rectangle zero will be used. If a geometry shader statically assigns a value togl_ViewportIndexand there is a path through the shader that does not assign a value togl_ViewportIndex, the value ofgl_ViewportIndexis undefined for executions of the shader that take that path.

In the fragment language,gl_ViewportIndexwill have the same value that was written to the output variablegl_ViewportIndexin the geometry stage. If the geometry stage does not dynamically assign togl_ViewportIndex, the value ofgl_ViewportIndexin the fragment shader will be undefined. If the geometry stage makes no static assignment togl_ViewportIndex, the fragment stage will read zero. Otherwise, the fragment stage will read the same value written by the geometry stage, even if that value is out of range. If a fragment shader contains a static access togl_ViewportIndex, it will count against the implementation defined limit for the maximum number of inputs to the fragment stage.


Version Support[edit]

gl_ViewportIndex (geometry stage) 1.5+
gl_ViewportIndex (fragment stage) 4.3+

See Also[edit]

 gl_Layer 


Copyright[edit]

Copyright© 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.