home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1993-94, Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that the name of Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE
- * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
- */
- #include <GL/glx.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- static const char* ClassOf(int c)
- {
- switch (c) {
- case StaticGray: return "StaticGray";
- case GrayScale: return "GrayScale";
- case StaticColor: return "StaticColor";
- case PseudoColor: return "PseudoColor";
- case TrueColor: return "TrueColor";
- case DirectColor: return "DirectColor";
- default: return "unknown";
- }
- }
-
- static void DumpGLXProperties(Display *dpy, XVisualInfo *vi)
- {
- int bufferSize, level, rgba, doubleBuffer, stereo, auxBuffers,
- redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize,
- accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize;
-
- glXGetConfig(dpy, vi, GLX_BUFFER_SIZE, &bufferSize);
- glXGetConfig(dpy, vi, GLX_LEVEL, &level);
- glXGetConfig(dpy, vi, GLX_RGBA, &rgba);
- glXGetConfig(dpy, vi, GLX_DOUBLEBUFFER, &doubleBuffer);
- glXGetConfig(dpy, vi, GLX_STEREO, &stereo);
- glXGetConfig(dpy, vi, GLX_AUX_BUFFERS, &auxBuffers);
- glXGetConfig(dpy, vi, GLX_RED_SIZE, &redSize);
- glXGetConfig(dpy, vi, GLX_GREEN_SIZE, &greenSize);
- glXGetConfig(dpy, vi, GLX_BLUE_SIZE, &blueSize);
- glXGetConfig(dpy, vi, GLX_ALPHA_SIZE, &alphaSize);
- glXGetConfig(dpy, vi, GLX_DEPTH_SIZE, &depthSize);
- glXGetConfig(dpy, vi, GLX_STENCIL_SIZE, &stencilSize);
- glXGetConfig(dpy, vi, GLX_ACCUM_RED_SIZE, &accumRedSize);
- glXGetConfig(dpy, vi, GLX_ACCUM_GREEN_SIZE, &accumGreenSize);
- glXGetConfig(dpy, vi, GLX_ACCUM_BLUE_SIZE, &accumBlueSize);
- glXGetConfig(dpy, vi, GLX_ACCUM_ALPHA_SIZE, &accumAlphaSize);
-
- printf(" bufferSize=%d level=%d rgba=%d doubleBuffer=%d stereo=%d\n",
- bufferSize, level, rgba, doubleBuffer, stereo);
- printf(" rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
- redSize, greenSize, blueSize, alphaSize);
- printf(" auxBuffers=%d depthSize=%d stencilSize=%d\n",
- auxBuffers, depthSize, stencilSize);
- printf(" accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
- accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize);
- }
-
- int main()
- {
- XVisualInfo match, *vi;
- Display *dpy;
- int found;
-
- dpy = XOpenDisplay(0);
- if (!dpy) {
- fprintf(stderr, "Can't connect to display \"%s\"\n", getenv("DISPLAY"));
- return -1;
- }
-
- match.screen = DefaultScreen(dpy);
- vi = XGetVisualInfo(dpy, VisualScreenMask, &match, &found);
- while (--found >= 0) {
- int value;
- glXGetConfig(dpy, vi, GLX_USE_GL, &value);
- if (value) {
- printf("Visual ID: %x depth=%2d class=%s\n",
- vi->visualid, vi->depth, ClassOf(vi->class));
- DumpGLXProperties(dpy, vi);
- }
- vi++;
- }
- return 0;
- }
-