logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

gl_ViewportIndex - contains the index of the viewport to be used in viewport transformation and

Declaration

       // In geometry shaders

       out int gl_ViewportIndex ;

       // In fragment shaders

       in int gl_ViewportIndex ;

Description

       In the geometry language, gl_ViewportIndex is 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 of gl_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 to gl_ViewportIndex, viewport transform and
       scissor rectangle zero will be used. If a geometry shader statically assigns a value to gl_ViewportIndex
       and there is a path through the shader that does not assign a value to gl_ViewportIndex, the value of
       gl_ViewportIndex is undefined for executions of the shader that take that path.

       In the fragment language, gl_ViewportIndex will have the same value that was written to the output
       variable gl_ViewportIndex in the geometry stage. If the geometry stage does not dynamically assign to
       gl_ViewportIndex, the value of gl_ViewportIndex in the fragment shader will be undefined. If the geometry
       stage makes no static assignment to gl_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 to gl_ViewportIndex, it will count against the
       implementation defined limit for the maximum number of inputs to the fragment stage.

Name

       gl_ViewportIndex - contains the index of the viewport to be used in viewport transformation and
       scissoring

See Also

gl_Layer()

Version Support

       ┌──────────────────┬───────────────────────────────────────────────────────────────────────────────────┐
       │                  │        OpenGLShadingLanguageVersion                                            │
       ├──────────────────┼──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┤
       │ Function1.101.201.301.401.503.304.004.104.204.304.404.50 │
       │ Name             │      │      │      │      │      │      │      │      │      │      │      │      │
       ├──────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
       │ gl_ViewportIndex │  -   │  -   │  -   │  -   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │
       │ (geometry        │      │      │      │      │      │      │      │      │      │      │      │      │
       │ stage)           │      │      │      │      │      │      │      │      │      │      │      │      │
       ├──────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
       │ gl_ViewportIndex │  -   │  -   │  -   │  -   │  -   │  -   │  -   │  -   │  -   │  ✔   │  ✔   │  ✔   │
       │ (fragment stage) │      │      │      │      │      │      │      │      │      │      │      │      │
       └──────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┘

See Also