Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame^] | 1 | /* $Id: glxinfo.c,v 1.1 1999/09/16 16:40:46 brianp Exp $ */ |
| 2 | |
| 3 | |
| 4 | /* |
| 5 | * Query GLX extensions, version, vendor, etc. |
| 6 | * This program is in the public domain. |
| 7 | * brian_paul@mesa3d.org |
| 8 | */ |
| 9 | |
| 10 | |
| 11 | |
| 12 | #include <GL/gl.h> |
| 13 | #include <GL/glx.h> |
| 14 | #include <GL/glu.h> |
| 15 | #include <stdio.h> |
| 16 | #include <stdlib.h> |
| 17 | |
| 18 | |
| 19 | |
| 20 | static void |
| 21 | query_glx( Display *dpy, int scr ) |
| 22 | { |
| 23 | printf("GL_VERSION: %s\n", (char *) glGetString(GL_VERSION)); |
| 24 | printf("GL_EXTENSIONS: %s\n", (char *) glGetString(GL_EXTENSIONS)); |
| 25 | printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); |
| 26 | printf("GL_VENDOR: %s\n", (char *) glGetString(GL_VENDOR)); |
| 27 | printf("GLU_VERSION: %s\n", (char *) gluGetString(GLU_VERSION)); |
| 28 | printf("GLU_EXTENSIONS: %s\n", (char *) gluGetString(GLU_EXTENSIONS)); |
| 29 | |
| 30 | printf("server GLX_VENDOR: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_VENDOR)); |
| 31 | printf("server GLX_VERSION: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_VERSION)); |
| 32 | printf("server GLX_EXTENSIONS: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_EXTENSIONS)); |
| 33 | |
| 34 | printf("client GLX_VENDOR: %s\n", (char *) glXGetClientString( dpy, GLX_VENDOR)); |
| 35 | printf("client GLX_VERSION: %s\n", (char *) glXGetClientString( dpy, GLX_VERSION)); |
| 36 | printf("client GLX_EXTENSIONS: %s\n", (char *) glXGetClientString( dpy, GLX_EXTENSIONS)); |
| 37 | |
| 38 | printf("GLX extensions: %s\n", (char *) glXQueryExtensionsString(dpy, scr)); |
| 39 | } |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | int |
| 45 | main( int argc, char *argv[] ) |
| 46 | { |
| 47 | Display *dpy; |
| 48 | Window win; |
| 49 | int attrib[] = { GLX_RGBA, |
| 50 | GLX_RED_SIZE, 1, |
| 51 | GLX_GREEN_SIZE, 1, |
| 52 | GLX_BLUE_SIZE, 1, |
| 53 | None }; |
| 54 | int scrnum; |
| 55 | XSetWindowAttributes attr; |
| 56 | unsigned long mask; |
| 57 | Window root; |
| 58 | GLXContext ctx; |
| 59 | XVisualInfo *visinfo; |
| 60 | int width = 100, height = 100; |
| 61 | |
| 62 | dpy = XOpenDisplay(NULL); |
| 63 | if (!dpy) { |
| 64 | fprintf(stderr, "Unable to open default display!\n"); |
| 65 | return 1; |
| 66 | } |
| 67 | |
| 68 | scrnum = DefaultScreen( dpy ); |
| 69 | root = RootWindow( dpy, scrnum ); |
| 70 | |
| 71 | visinfo = glXChooseVisual( dpy, scrnum, attrib ); |
| 72 | if (!visinfo) { |
| 73 | fprintf(stderr, "Error: couldn't find RGB GLX visual!\n"); |
| 74 | return 1; |
| 75 | } |
| 76 | |
| 77 | /* window attributes */ |
| 78 | attr.background_pixel = 0; |
| 79 | attr.border_pixel = 0; |
| 80 | attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); |
| 81 | attr.event_mask = StructureNotifyMask | ExposureMask; |
| 82 | mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; |
| 83 | |
| 84 | win = XCreateWindow( dpy, root, 0, 0, width, height, |
| 85 | 0, visinfo->depth, InputOutput, |
| 86 | visinfo->visual, mask, &attr ); |
| 87 | |
| 88 | ctx = glXCreateContext( dpy, visinfo, NULL, True ); |
| 89 | |
| 90 | glXMakeCurrent( dpy, win, ctx ); |
| 91 | |
| 92 | query_glx(dpy, scrnum); |
| 93 | |
| 94 | glXDestroyContext(dpy, ctx); |
| 95 | XDestroyWindow(dpy, win); |
| 96 | XCloseDisplay(dpy); |
| 97 | |
| 98 | return 0; |
| 99 | } |