GLXCHOOSEVISUAL(3gl)
β¨ GLXCHOOSEVISUAL(3G) β¨
okay bestie, buckle up, this is the glXChooseVisual page from the GLX manual (section 3G, the graphics-girlies section π ). it's giving "help me pick a visual" and honestly? it's iconic.
π NAME π
glXChooseVisual β return a visual that matches specified attributes
πΈ C SPECIFICATION πΈ
XVisualInfo* glXChooseVisual( Display *dpy,
int screen,
int *attribList )
delim $$
π¦ PARAMETERS π¦
dpyβ the connection to the X server. your lil phone line to the display, fr fr.screenβ the screen number.attribListβ a list of boolean attributes and integer attribute/value pairs. and listen, the last attribute must beNone. no cap.
π DESCRIPTION π
glXChooseVisual returns a pointer to an XVisualInfo structure describing the visual that best meets a minimum specification. slay.
the boolean GLX attributes of the visual that gets returned will match the specified values, and the integer GLX attributes will meet or exceed the specified minimum values. and here's the cute part: if all other attributes are equivalent, then TrueColor and PseudoColor visuals have priority over DirectColor and StaticColor visuals, respectively. it's giving ranked-choice voting π³οΈβ¨
if no conforming visual exists, NULL is returned. to free the data returned by this function, use XFree. (yes bestie, you gotta clean up after yourself, that's the vibe.)
all boolean GLX attributes default to False except GLX_USE_GL, which defaults to True. all integer GLX attributes default to zero. default specifications are superseded by attributes included in attribList. boolean attributes included in attribList are understood to be True. integer attributes and enumerated type attributes are followed immediately by the corresponding desired or minimum value. and the list must be terminated with None. periodt.
the interpretations of the various GLX visual attributes are as follows, and yes we're doing all of them, every single one, no skips:
GLX_USE_GLβ ignored. only visuals that can be rendered with GLX are considered. (she's just there for the plot, but the plot still requires her.)GLX_BUFFER_SIZEβ must be followed by a nonnegative integer that indicates the desired color index buffer size. the smallest index buffer of at least the specified size is preferred. ignored ifGLX_RGBAis asserted.GLX_LEVELβ must be followed by an integer buffer-level specification. this specification is honored exactly. buffer level zero corresponds to the main frame buffer of the display. buffer level one is the first overlay frame buffer, level two the second overlay frame buffer, and so on. negative buffer levels correspond to underlay frame buffers. (levels, layers, lore π )GLX_RGBAβ if present, onlyTrueColorandDirectColorvisuals are considered. otherwise, onlyPseudoColorandStaticColorvisuals are considered.GLX_DOUBLEBUFFERβ if present, only double-buffered visuals are considered. otherwise, only single-buffered visuals are considered.GLX_STEREOβ if present, only stereo visuals are considered. otherwise, only monoscopic visuals are considered.GLX_AUX_BUFFERSβ must be followed by a nonnegative integer that indicates the desired number of auxiliary buffers. visuals with the smallest number of auxiliary buffers that meets or exceeds the specified number are preferred.GLX_RED_SIZEβ must be followed by a nonnegative minimum size specification. if this value is zero, the smallest available red buffer is preferred. otherwise, the largest available red buffer of at least the minimum size is preferred.GLX_GREEN_SIZEβ must be followed by a nonnegative minimum size specification. if this value is zero, the smallest available green buffer is preferred. otherwise, the largest available green buffer of at least the minimum size is preferred.GLX_BLUE_SIZEβ must be followed by a nonnegative minimum size specification. if this value is zero, the smallest available blue buffer is preferred. otherwise, the largest available blue buffer of at least the minimum size is preferred.GLX_ALPHA_SIZEβ must be followed by a nonnegative minimum size specification. if this value is zero, the smallest available alpha buffer is preferred. otherwise, the largest available alpha buffer of at least the minimum size is preferred.GLX_DEPTH_SIZEβ must be followed by a nonnegative minimum size specification. if this value is zero, visuals with no depth buffer are preferred. otherwise, the largest available depth buffer of at least the minimum size is preferred.GLX_STENCIL_SIZEβ must be followed by a nonnegative integer that indicates the desired number of stencil bitplanes. the smallest stencil buffer of at least the specified size is preferred. if the desired value is zero, visuals with no stencil buffer are preferred.GLX_ACCUM_RED_SIZEβ must be followed by a nonnegative minimum size specification. if this value is zero, visuals with no red accumulation buffer are preferred. otherwise, the largest possible red accumulation buffer of at least the minimum size is preferred.GLX_ACCUM_GREEN_SIZEβ must be followed by a nonnegative minimum size specification. if this value is zero, visuals with no green accumulation buffer are preferred. otherwise, the largest possible green accumulation buffer of at least the minimum size is preferred.GLX_ACCUM_BLUE_SIZEβ must be followed by a nonnegative minimum size specification. if this value is zero, visuals with no blue accumulation buffer are preferred. otherwise, the largest possible blue accumulation buffer of at least the minimum size is preferred.GLX_ACCUM_ALPHA_SIZEβ must be followed by a nonnegative minimum size specification. if this value is zero, visuals with no alpha accumulation buffer are preferred. otherwise, the largest possible alpha accumulation buffer of at least the minimum size is preferred.
π EXAMPLES π
attribList =
{GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4, None};
so what's this one doing? it specifies a single-buffered RGB visual in the normal frame buffer β not an overlay or underlay buffer. the returned visual supports at least four bits each of red, green, and blue, and possibly no bits of alpha. it does not support color index mode, double-buffering, or stereo display. and it may or may not have one or more auxiliary color buffers, a depth buffer, a stencil buffer, or an accumulation buffer. (she's mysterious like that π)
π NOTES π
XVisualInfo is defined in Xutil.h. it's a structure that includes visual, visualID, screen, and depth elements.
glXChooseVisual is implemented as a client-side utility using only XGetVisualInfo and glXGetConfig. calls to these two routines can be used to implement selection algorithms other than the generic one implemented by glXChooseVisual. (iykyk, you can build your own.)
GLX implementers are strongly discouraged, but not proscribed, from changing the selection algorithm used by glXChooseVisual. therefore, selections may change from release to release of the client-side library. so don't come crying to me when your visual switches up on you bestie, it's literally documented π
there is no direct filter for picking only visuals that support GLXPixmaps. GLXPixmaps are supported for visuals whose GLX_BUFFER_SIZE is one of the pixmap depths supported by the X server.
π ERRORS π
NULL is returned if an undefined GLX attribute is encountered in attribList. (rip, undefined behavior jumpscare, but it's just a NULL, breathe.)
β SEE ALSO β
glXCreateContextglXGetConfig
and that's the whole page bestie, no crumbs left π«Ά this was the GLXCHOOSEVISUAL manual page β footer and all, that's the page name GLXCHOOSEVISUAL() sitting down there, part of the GLX docs, and honestly? she ate. go pick a visual, you got this ππ
π¦ where this page comes from
- opensuse-leap 16.0: Mesa-libGL-devel 24.1.7-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms