summaryrefslogtreecommitdiff
path: root/progs/xdemos/glxinfo.c
blob: e9ac47462c77b22ea3c5978e12589bf10aa331a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* $Id: glxinfo.c,v 1.1 1999/09/16 16:40:46 brianp Exp $ */


/*
 * Query GLX extensions, version, vendor, etc.
 * This program is in the public domain.
 * brian_paul@mesa3d.org
 */



#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
#include <stdio.h>
#include <stdlib.h>



static void
query_glx( Display *dpy, int scr )
{
   printf("GL_VERSION: %s\n", (char *) glGetString(GL_VERSION));
   printf("GL_EXTENSIONS: %s\n", (char *) glGetString(GL_EXTENSIONS));
   printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER));
   printf("GL_VENDOR: %s\n", (char *) glGetString(GL_VENDOR));
   printf("GLU_VERSION: %s\n", (char *) gluGetString(GLU_VERSION));
   printf("GLU_EXTENSIONS: %s\n", (char *) gluGetString(GLU_EXTENSIONS));

   printf("server GLX_VENDOR: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_VENDOR));
   printf("server GLX_VERSION: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_VERSION));
   printf("server GLX_EXTENSIONS: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_EXTENSIONS));

   printf("client GLX_VENDOR: %s\n", (char *) glXGetClientString( dpy, GLX_VENDOR));
   printf("client GLX_VERSION: %s\n", (char *) glXGetClientString( dpy, GLX_VERSION));
   printf("client GLX_EXTENSIONS: %s\n", (char *) glXGetClientString( dpy, GLX_EXTENSIONS));

   printf("GLX extensions: %s\n", (char *) glXQueryExtensionsString(dpy, scr));
}




int
main( int argc, char *argv[] )
{
   Display *dpy;
   Window win;
   int attrib[] = { GLX_RGBA,
		    GLX_RED_SIZE, 1,
		    GLX_GREEN_SIZE, 1,
		    GLX_BLUE_SIZE, 1,
		    None };
   int scrnum;
   XSetWindowAttributes attr;
   unsigned long mask;
   Window root;
   GLXContext ctx;
   XVisualInfo *visinfo;
   int width = 100, height = 100;

   dpy = XOpenDisplay(NULL);
   if (!dpy) {
      fprintf(stderr, "Unable to open default display!\n");
      return 1;
   }

   scrnum = DefaultScreen( dpy );
   root = RootWindow( dpy, scrnum );

   visinfo = glXChooseVisual( dpy, scrnum, attrib );
   if (!visinfo) {
      fprintf(stderr, "Error: couldn't find RGB GLX visual!\n");
      return 1;
   }

   /* window attributes */
   attr.background_pixel = 0;
   attr.border_pixel = 0;
   attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
   attr.event_mask = StructureNotifyMask | ExposureMask;
   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

   win = XCreateWindow( dpy, root, 0, 0, width, height,
		        0, visinfo->depth, InputOutput,
		        visinfo->visual, mask, &attr );

   ctx = glXCreateContext( dpy, visinfo, NULL, True );

   glXMakeCurrent( dpy, win, ctx );

   query_glx(dpy, scrnum);

   glXDestroyContext(dpy, ctx);
   XDestroyWindow(dpy, win);
   XCloseDisplay(dpy);

   return 0;
}