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β forglViewportIndexedf, these specify the lower left corner of the viewport rectangle, in pixels. the initial value is(0,0)βw,hβ forglViewportIndexedf, 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,wandhare set to the dimensions of that window πͺβ¨vβ forglViewportIndexedfv, 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_VALUEis generated ifindexis greater than or equal to the value ofGL_MAX_VIEWPORTSπ¬GL_INVALID_VALUEis generated if eitherworhis negative. yeah. negative width is not the move, don't do it π
π ASSOCIATED GETS π
glGet()with argumentGL_VIEWPORTglGet()with argumentGL_MAX_VIEWPORT_DIMSglGet()with argumentGL_VIEWPORT_BOUNDS_RANGEglGet()with argumentGL_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 π
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 (yes, again β the page really does this twice) π
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
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms