GLVIEWPORTARRAY(3G)

πŸ’– GLVIEWPORTARRAY(3G) πŸ’–

okay so bestie, this is glViewportArray from the [FIXME: manual] situation β€” yes the manual header literally says that, we love an unfinished glow-up πŸŽ€ β€” and it's the page about setting multiple viewports at once. plural. a whole squad of viewports. periodt.


✨ NAME ✨

glViewportArray β€” set multiple viewports πŸ¦‹


🌸 C SPECIFICATION 🌸

void glViewportArrayv(GLuint first, GLsizei count, const GLfloat *v);

that's it. that's the whole signature. copy it exactly, don't get creative πŸ’…


πŸŽ€ PARAMETERS πŸŽ€

  • first β€” the index of the first viewport you wanna set. like, where the party starts.
  • count β€” how many viewports you're setting. how many besties you're bringing.
  • v β€” the address of an array holding the viewport parameters. it's the bag with everybody's stuff in it.

πŸ’œ DESCRIPTION πŸ’œ

so glViewportArrayv specifies the parameters for multiple viewports simultaneously πŸ”₯. first is the index of the first viewport to modify, and count is the number of viewports to modify. first must be less than the value of GL_MAX_VIEWPORTS, and first + count must be less than or equal to the value of GL_MAX_VIEWPORTS. viewports whose indices lie outside the range [first, first + count) are not modified β€” they just stay in their lane, no cap 🧚.

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 y w are computed as follows:

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

y w = y nd + 1 ⁒ height 2 + y
iykyk, this is the mathy part, just copy it, don't @ me 😭

the location of the viewport's bottom left corner, given by (x, y), is clamped to be within the implementation-dependent viewport bounds range. 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, like it's not gonna 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 ✨.


πŸ’€ ERRORS πŸ’€

  • GL_INVALID_VALUE is generated if first is greater than or equal to the value of GL_MAX_VIEWPORTS.
  • GL_INVALID_VALUE is generated if first + count is greater than or equal to the value of GL_MAX_VIEWPORTS.
  • GL_INVALID_VALUE is generated if either width or height is negative.

like, three whole ways to get read πŸ’…. negative width is not the vibe, bestie.


πŸ‘‘ 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

🌈 VERSION SUPPORT 🌈

the original ships this as a big table with the row label Function / Feature Name and a column header of OpenGL Version β€” here it is, de-tabled for your reading pleasure πŸ“:

  • glViewportArrayv
    • 2.0 β€” -
    • 2.1 β€” -
    • 3.0 β€” -
    • 3.1 β€” -
    • 3.2 β€” -
    • 3.3 β€” -
    • 4.0 β€” -
    • 4.1 β€” βœ”
    • 4.2 β€” βœ”
    • 4.3 β€” βœ”
    • 4.4 β€” βœ”
    • 4.5 β€” βœ”

so it's giving 4.1-and-up only. before that? not a thing. the -s said what they said πŸ™ˆ


🫢 SEE ALSO 🫢

  • glDepthRange()
  • glViewport()
  • glViewportIndexed()

go read those too, they're iconic in their own right πŸ’–


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


okay that's the page bestie!! no cap, you ate that reading. the footer energy: this came from [FIXME: source] and it's dated 08/09/2021, hitting you with the GLVIEWPORTARRAY(3G) one more time on the way out 🌸✨🫢

πŸ“¦ where this page comes from