GLVIEWPORTINDEXED(3G)

πŸ’… GLVIEWPORTINDEXED πŸ’… (3G, obviously)

okay so bestie, welcome to the GLVIEWPORTINDEXED page from the 3G manual section β€” this is the one about setting one specific viewport by index, and honestly it's giving "I only need to move one of my many little rectangles" energy πŸŽ€


✨ NAME ✨

glViewportIndexed β€” set a specified viewport. that's it. that's the whole name. slay πŸ’…


πŸŽ€ C SPECIFICATION πŸŽ€

here's the exact signature tea, no cap:

void glViewportIndexedf(GLuint index, GLfloat x, GLfloat y, GLfloat w,
                        GLfloat h);

void glViewportIndexedfv(GLuint index, const GLfloat *v);

🌸 PARAMETERS 🌸

  • index β€” the first viewport to set. like, which one are we touching bestie 🫢
  • x, y β€” for glViewportIndexedf, these specify the lower left corner of the viewport rectangle, in pixels. the initial value is (0,0) ⭐
  • w, h β€” for glViewportIndexedf, these specify the width and height of the viewport. and here's the cute detail: when a GL context is first attached to a window, w and h are set to the dimensions of that window πŸͺŸβœ¨
  • v β€” for glViewportIndexedfv, this specifies the address of an array containing the viewport parameters. it's a pointer, she's pointing at stuff, periodt πŸ’€

πŸ¦‹ DESCRIPTION πŸ¦‹

so glViewportIndexedf and glViewportIndexedfv specify the parameters for a single viewport. index specifies the index of the viewport to modify, and index must be less than the value of GL_MAX_VIEWPORTS β€” that's the vibe check, don't fail it πŸ™ˆ

for glViewportIndexedf, x, y, w, and h specify the left, bottom, width and height of the viewport in pixels, respectively. icon behavior.

for glViewportIndexedfv, v contains the address of an array of floating point values specifying the left (x), bottom (y), width (w), and height (h) of each viewport, in that order. x and y give the location of the viewport's lower left corner, and w and h give the width and height of the viewport, respectively 🧚

the viewport specifies the affine transformation of x and y from normalized device coordinates to window coordinates. let x nd and y nd be normalized device coordinates. then the window coordinates x w and y w are computed as follows:

x w = x nd + 1 ⁒ width 2 + x
y w = y nd + 1 ⁒ height 2 + y

the location of the viewport's bottom left corner, given by (x, y), is clamped to be within the implementation-dependent viewport bounds range. and like β€” you can find out what that range is! the viewport bounds range [min, max] can be determined by calling glGet() with argument GL_VIEWPORT_BOUNDS_RANGE 🌈

viewport width and height are silently clamped to a range that depends on the implementation β€” silently, bestie, she doesn't even tell you 😭 to query this range, call glGet() with argument GL_MAX_VIEWPORT_DIMS.

the precision with which the GL interprets the floating point viewport bounds is implementation-dependent and may be determined by querying the implementation-defined constant GL_VIEWPORT_SUBPIXEL_BITS πŸ”

calling glViewportIndexedfv is equivalent to calling glViewportArray() with first set to index, count set to 1 and v passed directly. and glViewportIndexedf is equivalent to this whole little guy right here:

void glViewportIndexedf(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h) {
    const float v[4]  = { x, y, w, h };
    glViewportArrayv(index, 1, v);
}

like, it's literally just wrapping the array version. main character energy for a helper function, honestly πŸ‘‘


πŸ”₯ ERRORS πŸ”₯

  • GL_INVALID_VALUE is generated if index is greater than or equal to the value of GL_MAX_VIEWPORTS 😬
  • GL_INVALID_VALUE is generated if either w or h is negative. yeah. negative width is not the move, don't do it πŸ’€

πŸ‘‘ ASSOCIATED GETS πŸ‘‘

  • glGet() with argument GL_VIEWPORT
  • glGet() with argument GL_MAX_VIEWPORT_DIMS
  • glGet() with argument GL_VIEWPORT_BOUNDS_RANGE
  • glGet() with argument GL_VIEWPORT_SUBPIXEL_BITS

all the glGet() calls you could ever want, fr fr 🫢


⭐ VERSION SUPPORT ⭐

so the original had a whole big grid, and I'm gonna give you the exact same info in list form because tables are not the vibe here:

  • glViewportIndexedf β€” 2.0: -, 2.1: -, 3.0: -, 3.1: -, 3.2: -, 3.3: -, 4.0: -, 4.1: βœ”, 4.2: βœ”, 4.3: βœ”, 4.4: βœ”, 4.5: βœ”
  • glViewportIndexedfv β€” 2.0: -, 2.1: -, 3.0: -, 3.1: -, 3.2: -, 3.3: -, 4.0: -, 4.1: βœ”, 4.2: βœ”, 4.3: βœ”, 4.4: βœ”, 4.5: βœ”

tl;dr: it shows up in 4.1 and stays winning through 4.5 ✨ everyone before 4.1? not invited 🚫


🌈 SEE ALSO 🌈

  • glDepthRange()
  • glViewport()
  • glViewportArray()

go read your other faves, iykyk πŸ’–


Copyright Β© 2010-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/.


Copyright Β© 2010-2014 Khronos Group


ok that's the whole page, you made it to the end, I'm so proud of you πŸ₯ΉπŸ’

and for the cute sign-off: this little number came from [FIXME: source], dated 08/09/2021, and it lives under GLVIEWPORTINDEXED(3G) β€” go forth and set exactly one viewport, bestie πŸŒΈπŸ¦‹πŸ’…

πŸ“¦ where this page comes from