next up previous
Next: 3.2.3 Off Screen Rendering Up: 3.2 Functions Previous: 3.2.1 Initialization

3.2.2 Configuration Management

The constants shown in Table 1 are passed to glXGetConfig and glXChooseVisual to specify which attributes are being queried.

  
Table 1: Configuration attributes.

Note that GLX _BUFFER _SIZE gives the total depth of the color buffer in bits. For Visuals of type color index, this is exactly the same value as that reported in the core X11 Visual. For Visuals of type RGB, GLX _BUFFER _SIZE will include alpha planes that may or may not be reported in the core X11 Visual.

To obtain a description of an OpenGL attribute exported by a Visual use

int glXGetConfig ( Display *dpy , XVisualInfo* *visual , int attribute , int *value ) ;

glXGetConfig returns through value the value of the attribute of visual.

glXGetConfig returns one of the following error codes if it fails, and Success otherwise:

GLX _NO _EXTENSION dpy does not support the GLX extension.

GLX _BAD _SCREEN screen of visual does not correspond to a screen.

GLX _BAD _ATTRIB attribute is not a valid GLX attribute.

GLX _BAD _VISUAL visual does not support GLX and an attribute other than GLX _USE _GL was specified.

GLX _BAD _CONTEXT wrong kind of context .e.g., direct or indirect.

GLX _BAD _VALUE parameter invalid

GLX _BAD _ENUM enum invalid

A GLX implementation may export many visuals that support OpenGL. These visuals support either color index or RGBA rendering. Servers must export at least one visual that supports RGBA rendering. If the X server exports a PseudoColor or StaticColor visual on framebuffer level 0 (the main image planes), a visual that supports color index rendering is also required. One of the visuals that supports RGBA rendering must have at least one color buffer, a stencil buffer of at least 1 bit, a depth buffer of at least 12 bits, and an accumulation buffer. Alpha bitplanes are optional in this visual. However, its color buffer size must be as great as that of the deepest TrueColor, DirectColor, PseudoColor, or StaticColor visual supported on framebuffer level zero, and it must itself be made available on framebuffer level zero.

One of the visuals that supports color index rendering must have at least one color buffer, a stencil buffer of at least 1 bit, and a depth buffer of at least 12 bits. It also must have as many color bitplanes as the deepest PseudoColor or StaticColor visual supported on framebuffer level zero, and it must itself be made available on level zero.

glXChooseVisual is used to find a visual that matches the client's specified attributes.

XVisualInfo* glXChooseVisual ( Display *dpy , int screen , int *attrib _list ) ;

glXChooseVisual returns a pointer to a XVisualInfo structure describing the visual that best meets a minimum specification. The boolean GLX attributes of the visual that is returned will match the specification exactly; the integer GLX attributes will meet or exceed the specified minimum values. If no conforming visual exists, NULL is returned.

If GLX _RGBA is in attrib _list then the resulting visual will be TrueColor or DirectColor. If all other attributes are equivalent, then a TrueColor visual will be chosen in preference to a DirectColor visual.

If GLX _RGBA is not in attrib _list then the returned visual will be PseudoColor or StaticColor. If all other attributes are equivalent then a PseudoColor visual will be chosen in preference to a StaticColor visual.

All boolean GLX attributes default to False except GLX _USE _GL, which defaults to True. All integer attributes default to zero.

Default specifications are superseded by the attributes included in attrib _list. Integer attributes are immediately followed by the corresponding desired value. Boolean attributes appearing in attrib _list have an implicit True value; such attributes are never followed by an explicit True or False value. The list is terminated with None.

To free the data returned, use XFree.

NULL is returned if an undefined GLX attribute is encountered.



next up previous
Next: 3.2.3 Off Screen Rendering Up: 3.2 Functions Previous: 3.2.1 Initialization



Mark Segal
Wed Jan 11 18:38:15 PST 1995