Merge branch 'gallium-0.1' into gallium-tex-surfaces
[mesa.git] / progs / tests / getprocaddress.c
1 /*
2 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 */
21
22 /*
23 * Test that glXGetProcAddress works.
24 */
25
26 #define GLX_GLXEXT_PROTOTYPES
27
28 #include <X11/Xlib.h>
29 #include <X11/Xutil.h>
30 #include <GL/gl.h>
31 #include <GL/glx.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <math.h>
36
37
38 typedef void (*generic_func)();
39
40 #define EQUAL(X, Y) (fabs((X) - (Y)) < 0.001)
41
42 /**
43 * The following functions are used to check that the named OpenGL function
44 * actually does what it's supposed to do.
45 * The naming of these functions is signficant. The getprocaddress.py script
46 * scans this file and extracts these function names.
47 */
48
49
50 static GLboolean
51 test_ActiveTextureARB(generic_func func)
52 {
53 PFNGLACTIVETEXTUREARBPROC activeTexture = (PFNGLACTIVETEXTUREARBPROC) func;
54 GLint t;
55 GLboolean pass;
56 (*activeTexture)(GL_TEXTURE1_ARB);
57 glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &t);
58 pass = (t == GL_TEXTURE1_ARB);
59 (*activeTexture)(GL_TEXTURE0_ARB); /* restore default */
60 return pass;
61 }
62
63
64 static GLboolean
65 test_SecondaryColor3fEXT(generic_func func)
66 {
67 PFNGLSECONDARYCOLOR3FEXTPROC secColor3f = (PFNGLSECONDARYCOLOR3FEXTPROC) func;
68 GLfloat color[4];
69 GLboolean pass;
70 (*secColor3f)(1.0, 1.0, 0.0);
71 glGetFloatv(GL_CURRENT_SECONDARY_COLOR_EXT, color);
72 pass = (color[0] == 1.0 && color[1] == 1.0 && color[2] == 0.0);
73 (*secColor3f)(0.0, 0.0, 0.0); /* restore default */
74 return pass;
75 }
76
77
78 static GLboolean
79 test_ActiveStencilFaceEXT(generic_func func)
80 {
81 PFNGLACTIVESTENCILFACEEXTPROC activeFace = (PFNGLACTIVESTENCILFACEEXTPROC) func;
82 GLint face;
83 GLboolean pass;
84 (*activeFace)(GL_BACK);
85 glGetIntegerv(GL_ACTIVE_STENCIL_FACE_EXT, &face);
86 pass = (face == GL_BACK);
87 (*activeFace)(GL_FRONT); /* restore default */
88 return pass;
89 }
90
91
92 static GLboolean
93 test_VertexAttrib1fvARB(generic_func func)
94 {
95 PFNGLVERTEXATTRIB1FVARBPROC vertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC) func;
96 PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
97
98 const GLfloat v[1] = {25.0};
99 const GLfloat def[1] = {0};
100 GLfloat res[4];
101 GLboolean pass;
102 (*vertexAttrib1fvARB)(6, v);
103 (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
104 pass = (res[0] == 25.0 && res[1] == 0.0 && res[2] == 0.0 && res[3] == 1.0);
105 (*vertexAttrib1fvARB)(6, def);
106 return pass;
107 }
108
109 static GLboolean
110 test_VertexAttrib4NubvARB(generic_func func)
111 {
112 PFNGLVERTEXATTRIB4NUBVARBPROC vertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC) func;
113 PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
114
115 const GLubyte v[4] = {255, 0, 255, 0};
116 const GLubyte def[4] = {0, 0, 0, 255};
117 GLfloat res[4];
118 GLboolean pass;
119 (*vertexAttrib4NubvARB)(6, v);
120 (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
121 pass = (res[0] == 1.0 && res[1] == 0.0 && res[2] == 1.0 && res[3] == 0.0);
122 (*vertexAttrib4NubvARB)(6, def);
123 return pass;
124 }
125
126
127 static GLboolean
128 test_VertexAttrib4NuivARB(generic_func func)
129 {
130 PFNGLVERTEXATTRIB4NUIVARBPROC vertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC) func;
131 PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
132
133 const GLuint v[4] = {0xffffffff, 0, 0xffffffff, 0};
134 const GLuint def[4] = {0, 0, 0, 0xffffffff};
135 GLfloat res[4];
136 GLboolean pass;
137 (*vertexAttrib4NuivARB)(6, v);
138 (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
139 pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 0.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
140 (*vertexAttrib4NuivARB)(6, def);
141 return pass;
142 }
143
144
145 static GLboolean
146 test_VertexAttrib4ivARB(generic_func func)
147 {
148 PFNGLVERTEXATTRIB4IVARBPROC vertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC) func;
149 PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
150
151 const GLint v[4] = {1, 2, -3, 4};
152 const GLint def[4] = {0, 0, 0, 1};
153 GLfloat res[4];
154 GLboolean pass;
155 (*vertexAttrib4ivARB)(6, v);
156 (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
157 pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 2.0) && EQUAL(res[2], -3.0) && EQUAL(res[3], 4.0));
158 (*vertexAttrib4ivARB)(6, def);
159 return pass;
160 }
161
162
163 static GLboolean
164 test_VertexAttrib4NsvARB(generic_func func)
165 {
166 PFNGLVERTEXATTRIB4NSVARBPROC vertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC) func;
167 PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
168
169 const GLshort v[4] = {0, 32767, 32767, 0};
170 const GLshort def[4] = {0, 0, 0, 32767};
171 GLfloat res[4];
172 GLboolean pass;
173 (*vertexAttrib4NsvARB)(6, v);
174 (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
175 pass = (EQUAL(res[0], 0.0) && EQUAL(res[1], 1.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
176 (*vertexAttrib4NsvARB)(6, def);
177 return pass;
178 }
179
180
181 static GLboolean
182 test_VertexAttrib4NusvARB(generic_func func)
183 {
184 PFNGLVERTEXATTRIB4NUSVARBPROC vertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC) func;
185 PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
186
187 const GLushort v[4] = {0xffff, 0, 0xffff, 0};
188 const GLushort def[4] = {0, 0, 0, 0xffff};
189 GLfloat res[4];
190 GLboolean pass;
191 (*vertexAttrib4NusvARB)(6, v);
192 (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
193 pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 0.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
194 (*vertexAttrib4NusvARB)(6, def);
195 return pass;
196 }
197
198
199 static GLboolean
200 test_VertexAttrib4ubNV(generic_func func)
201 {
202 PFNGLVERTEXATTRIB4UBNVPROC vertexAttrib4ubNV = (PFNGLVERTEXATTRIB4UBNVPROC) func;
203 PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
204
205 const GLubyte v[4] = {255, 0, 255, 0};
206 const GLubyte def[4] = {0, 0, 0, 255};
207 GLfloat res[4];
208 GLboolean pass;
209 (*vertexAttrib4ubNV)(6, v[0], v[1], v[2], v[3]);
210 (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
211 pass = (res[0] == 1.0 && res[1] == 0.0 && res[2] == 1.0 && res[3] == 0.0);
212 (*vertexAttrib4ubNV)(6, def[0], def[1], def[2], def[3]);
213 return pass;
214 }
215
216
217 static GLboolean
218 test_VertexAttrib2sNV(generic_func func)
219 {
220 PFNGLVERTEXATTRIB2SNVPROC vertexAttrib2sNV = (PFNGLVERTEXATTRIB2SNVPROC) func;
221 PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
222
223 const GLshort v[2] = {2, -4,};
224 const GLshort def[2] = {0, 0};
225 GLfloat res[4];
226 GLboolean pass;
227 (*vertexAttrib2sNV)(6, v[0], v[1]);
228 (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
229 pass = (EQUAL(res[0], 2) && EQUAL(res[1], -4) && EQUAL(res[2], 0) && res[3] == 1.0);
230 (*vertexAttrib2sNV)(6, def[0], def[1]);
231 return pass;
232 }
233
234
235 static GLboolean
236 test_VertexAttrib3fNV(generic_func func)
237 {
238 PFNGLVERTEXATTRIB3FNVPROC vertexAttrib3fNV = (PFNGLVERTEXATTRIB3FNVPROC) func;
239 PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
240
241 const GLfloat v[3] = {0.2, 0.4, 0.8};
242 const GLfloat def[3] = {0, 0, 0};
243 GLfloat res[4];
244 GLboolean pass;
245 (*vertexAttrib3fNV)(6, v[0], v[1], v[2]);
246 (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
247 pass = (EQUAL(res[0], 0.2) && EQUAL(res[1], 0.4) && EQUAL(res[2], 0.8) && res[3] == 1.0);
248 (*vertexAttrib3fNV)(6, def[0], def[1], def[2]);
249 return pass;
250 }
251
252
253 static GLboolean
254 test_VertexAttrib4dvNV(generic_func func)
255 {
256 PFNGLVERTEXATTRIB4DVNVPROC vertexAttrib4dvNV = (PFNGLVERTEXATTRIB4DVNVPROC) func;
257 PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
258
259 const GLdouble v[4] = {0.2, 0.4, 0.8, 1.2};
260 const GLdouble def[4] = {0, 0, 0, 1};
261 GLfloat res[4];
262 GLboolean pass;
263 (*vertexAttrib4dvNV)(6, v);
264 (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
265 pass = (EQUAL(res[0], 0.2) && EQUAL(res[1], 0.4) && EQUAL(res[2], 0.8) && EQUAL(res[3], 1.2));
266 (*vertexAttrib4dvNV)(6, def);
267 return pass;
268 }
269
270
271 static GLboolean
272 test_StencilFuncSeparateATI(generic_func func)
273 {
274 #ifdef GL_ATI_separate_stencil
275 PFNGLSTENCILFUNCSEPARATEATIPROC stencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) func;
276 GLint frontFunc, backFunc;
277 GLint frontRef, backRef;
278 GLint frontMask, backMask;
279 (*stencilFuncSeparateATI)(GL_LESS, GL_GREATER, 2, 0xa);
280 glGetIntegerv(GL_STENCIL_FUNC, &frontFunc);
281 glGetIntegerv(GL_STENCIL_BACK_FUNC, &backFunc);
282 glGetIntegerv(GL_STENCIL_REF, &frontRef);
283 glGetIntegerv(GL_STENCIL_BACK_REF, &backRef);
284 glGetIntegerv(GL_STENCIL_VALUE_MASK, &frontMask);
285 glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, &backMask);
286 if (frontFunc != GL_LESS ||
287 backFunc != GL_GREATER ||
288 frontRef != 2 ||
289 backRef != 2 ||
290 frontMask != 0xa ||
291 backMask != 0xa)
292 return GL_FALSE;
293 #endif
294 return GL_TRUE;
295 }
296
297 static GLboolean
298 test_StencilFuncSeparate(generic_func func)
299 {
300 #ifdef GL_VERSION_2_0
301 PFNGLSTENCILFUNCSEPARATEPROC stencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) func;
302 GLint frontFunc, backFunc;
303 GLint frontRef, backRef;
304 GLint frontMask, backMask;
305 (*stencilFuncSeparate)(GL_BACK, GL_GREATER, 2, 0xa);
306 glGetIntegerv(GL_STENCIL_FUNC, &frontFunc);
307 glGetIntegerv(GL_STENCIL_BACK_FUNC, &backFunc);
308 glGetIntegerv(GL_STENCIL_REF, &frontRef);
309 glGetIntegerv(GL_STENCIL_BACK_REF, &backRef);
310 glGetIntegerv(GL_STENCIL_VALUE_MASK, &frontMask);
311 glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, &backMask);
312 if (frontFunc != GL_ALWAYS ||
313 backFunc != GL_GREATER ||
314 frontRef != 0 ||
315 backRef != 2 ||
316 frontMask == 0xa || /* might be 0xff or ~0 */
317 backMask != 0xa)
318 return GL_FALSE;
319 #endif
320 return GL_TRUE;
321 }
322
323 static GLboolean
324 test_StencilOpSeparate(generic_func func)
325 {
326 #ifdef GL_VERSION_2_0
327 PFNGLSTENCILOPSEPARATEPROC stencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) func;
328 GLint frontFail, backFail;
329 GLint frontZFail, backZFail;
330 GLint frontZPass, backZPass;
331 (*stencilOpSeparate)(GL_BACK, GL_INCR, GL_DECR, GL_INVERT);
332 glGetIntegerv(GL_STENCIL_FAIL, &frontFail);
333 glGetIntegerv(GL_STENCIL_BACK_FAIL, &backFail);
334 glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &frontZFail);
335 glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_FAIL, &backZFail);
336 glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &frontZPass);
337 glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_PASS, &backZPass);
338 if (frontFail != GL_KEEP ||
339 backFail != GL_INCR ||
340 frontZFail != GL_KEEP ||
341 backZFail != GL_DECR ||
342 frontZPass != GL_KEEP ||
343 backZPass != GL_INVERT)
344 return GL_FALSE;
345 #endif
346 return GL_TRUE;
347 }
348
349 static GLboolean
350 test_StencilMaskSeparate(generic_func func)
351 {
352 #ifdef GL_VERSION_2_0
353 PFNGLSTENCILMASKSEPARATEPROC stencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) func;
354 GLint frontMask, backMask;
355 (*stencilMaskSeparate)(GL_BACK, 0x1b);
356 glGetIntegerv(GL_STENCIL_WRITEMASK, &frontMask);
357 glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, &backMask);
358 if (frontMask == 0x1b ||
359 backMask != 0x1b)
360 return GL_FALSE;
361 #endif
362 return GL_TRUE;
363 }
364
365
366 /*
367 * The following file is auto-generated with Python.
368 */
369 #include "getproclist.h"
370
371
372
373 static int
374 extension_supported(const char *haystack, const char *needle)
375 {
376 const char *p = strstr(haystack, needle);
377 if (p) {
378 /* found string, make sure next char is space or zero */
379 const int len = strlen(needle);
380 if (p[len] == ' ' || p[len] == 0)
381 return 1;
382 else
383 return 0;
384 }
385 else
386 return 0;
387 }
388
389
390 static void
391 check_functions( const char *extensions )
392 {
393 struct name_test_pair *entry;
394 int failures = 0, passes = 0;
395 int totalFail = 0, totalPass = 0;
396 int doTests;
397
398 for (entry = functions; entry->name; entry++) {
399 if (entry->name[0] == '-') {
400 const char *version = (const char *) glGetString(GL_VERSION);
401 if (entry->name[1] == '1') {
402 /* check GL version 1.x */
403 if (version[0] == '1' &&
404 version[1] == '.' &&
405 version[2] >= entry->name[3])
406 doTests = 1;
407 else
408 doTests = 0;
409 }
410 else if (entry->name[1] == '2') {
411 if (version[0] == '2' &&
412 version[1] == '.' &&
413 version[2] >= entry->name[3])
414 doTests = 1;
415 else
416 doTests = 0;
417 }
418 else {
419 /* check if the named extension is available */
420 doTests = extension_supported(extensions, entry->name+1);
421 }
422 if (doTests)
423 printf("Testing %s functions\n", entry->name + 1);
424 totalFail += failures;
425 totalPass += passes;
426 failures = 0;
427 passes = 0;
428 }
429 else if (doTests) {
430 generic_func funcPtr = (generic_func) glXGetProcAddressARB((const GLubyte *) entry->name);
431 if (funcPtr) {
432 if (entry->test) {
433 GLboolean b;
434 printf(" Validating %s:", entry->name);
435 b = (*entry->test)(funcPtr);
436 if (b) {
437 printf(" Pass\n");
438 passes++;
439 }
440 else {
441 printf(" FAIL!!!\n");
442 failures++;
443 }
444 }
445 else {
446 passes++;
447 }
448 }
449 else {
450 printf(" glXGetProcAddress(%s) failed!\n", entry->name);
451 failures++;
452 }
453 }
454
455 if (doTests && (!(entry+1)->name || (entry+1)->name[0] == '-')) {
456 if (failures > 0) {
457 printf(" %d failed.\n", failures);
458 }
459 if (passes > 0) {
460 printf(" %d passed.\n", passes);
461 }
462 }
463 }
464 totalFail += failures;
465 totalPass += passes;
466
467 printf("-----------------------------\n");
468 printf("Total: %d pass %d fail\n", totalPass, totalFail);
469 }
470
471
472
473 static void
474 print_screen_info(Display *dpy, int scrnum, Bool allowDirect)
475 {
476 Window win;
477 int attribSingle[] = {
478 GLX_RGBA,
479 GLX_RED_SIZE, 1,
480 GLX_GREEN_SIZE, 1,
481 GLX_BLUE_SIZE, 1,
482 GLX_STENCIL_SIZE, 1,
483 None };
484 int attribDouble[] = {
485 GLX_RGBA,
486 GLX_RED_SIZE, 1,
487 GLX_GREEN_SIZE, 1,
488 GLX_BLUE_SIZE, 1,
489 GLX_STENCIL_SIZE, 1,
490 GLX_DOUBLEBUFFER,
491 None };
492
493 XSetWindowAttributes attr;
494 unsigned long mask;
495 Window root;
496 GLXContext ctx;
497 XVisualInfo *visinfo;
498 int width = 100, height = 100;
499
500 root = RootWindow(dpy, scrnum);
501
502 visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
503 if (!visinfo) {
504 visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
505 if (!visinfo) {
506 fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
507 return;
508 }
509 }
510
511 attr.background_pixel = 0;
512 attr.border_pixel = 0;
513 attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
514 attr.event_mask = StructureNotifyMask | ExposureMask;
515 mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
516 win = XCreateWindow(dpy, root, 0, 0, width, height,
517 0, visinfo->depth, InputOutput,
518 visinfo->visual, mask, &attr);
519
520 ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
521 if (!ctx) {
522 fprintf(stderr, "Error: glXCreateContext failed\n");
523 XDestroyWindow(dpy, win);
524 return;
525 }
526
527 if (glXMakeCurrent(dpy, win, ctx)) {
528 check_functions( (const char *) glGetString(GL_EXTENSIONS) );
529 }
530 else {
531 fprintf(stderr, "Error: glXMakeCurrent failed\n");
532 }
533
534 glXDestroyContext(dpy, ctx);
535 XDestroyWindow(dpy, win);
536 }
537
538
539 int
540 main(int argc, char *argv[])
541 {
542 char *displayName = NULL;
543 Display *dpy;
544
545 dpy = XOpenDisplay(displayName);
546 if (!dpy) {
547 fprintf(stderr, "Error: unable to open display %s\n", displayName);
548 return -1;
549 }
550
551 print_screen_info(dpy, 0, GL_TRUE);
552
553 XCloseDisplay(dpy);
554
555 return 0;
556 }