2 * Copyright (C) 2009 VMware, Inc.
3 * Copyright (C) 1999-2006 Brian Paul
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * This program is a work-alike of the GLX glxinfo program.
27 * Command line options:
29 * -v print verbose information
30 * -b only print ID of "best" visual on screen 0
31 * -l print interesting OpenGL limits (added 5 Sep 2002)
38 #include <GL/wglext.h>
53 * Print a list of extensions, with word-wrapping.
56 print_extension_list(const char *ext
)
58 const char *indentString
= " ";
70 if (ext
[j
] == ' ' || ext
[j
] == 0) {
71 /* found end of an extension name */
72 const int len
= j
- i
;
73 if (width
+ len
> max
) {
74 /* start a new line */
79 /* print the extension name between ext[i] and ext[j] */
84 /* either we're all done, or we'll continue with next extension */
105 * Print interesting limits for vertex/fragment programs.
108 print_program_limits(GLenum target
)
110 #if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
115 static const struct token_name limits
[] = {
116 { GL_MAX_PROGRAM_INSTRUCTIONS_ARB
, "GL_MAX_PROGRAM_INSTRUCTIONS_ARB" },
117 { GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" },
118 { GL_MAX_PROGRAM_TEMPORARIES_ARB
, "GL_MAX_PROGRAM_TEMPORARIES_ARB" },
119 { GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" },
120 { GL_MAX_PROGRAM_PARAMETERS_ARB
, "GL_MAX_PROGRAM_PARAMETERS_ARB" },
121 { GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB" },
122 { GL_MAX_PROGRAM_ATTRIBS_ARB
, "GL_MAX_PROGRAM_ATTRIBS_ARB" },
123 { GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB
, "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB" },
124 { GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB
, "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB" },
125 { GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB
, "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" },
126 { GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
, "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB" },
127 { GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB" },
128 { GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB
, "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" },
129 { GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB
, "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" },
130 { GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB
, "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB" },
131 { GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB
, "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" },
132 { GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB
, "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" },
133 { GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB
, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" },
136 PFNGLGETPROGRAMIVARBPROC GetProgramivARB_func
= (PFNGLGETPROGRAMIVARBPROC
)
137 wglGetProcAddress("glGetProgramivARB");
141 if (target
== GL_VERTEX_PROGRAM_ARB
) {
142 printf(" GL_VERTEX_PROGRAM_ARB:\n");
144 else if (target
== GL_FRAGMENT_PROGRAM_ARB
) {
145 printf(" GL_FRAGMENT_PROGRAM_ARB:\n");
148 return; /* something's wrong */
151 for (i
= 0; limits
[i
].token
; i
++) {
152 GetProgramivARB_func(target
, limits
[i
].token
, max
);
153 if (glGetError() == GL_NO_ERROR
) {
154 printf(" %s = %d\n", limits
[i
].name
, max
[0]);
157 #endif /* GL_ARB_vertex_program / GL_ARB_fragment_program */
162 * Print interesting limits for vertex/fragment shaders.
165 print_shader_limits(GLenum target
)
171 #if defined(GL_ARB_vertex_shader)
172 static const struct token_name vertex_limits
[] = {
173 { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
, "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB" },
174 { GL_MAX_VARYING_FLOATS_ARB
, "GL_MAX_VARYING_FLOATS_ARB" },
175 { GL_MAX_VERTEX_ATTRIBS_ARB
, "GL_MAX_VERTEX_ATTRIBS_ARB" },
176 { GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" },
177 { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" },
178 { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" },
179 { GL_MAX_TEXTURE_COORDS_ARB
, "GL_MAX_TEXTURE_COORDS_ARB" },
183 #if defined(GL_ARB_fragment_shader)
184 static const struct token_name fragment_limits
[] = {
185 { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" },
186 { GL_MAX_TEXTURE_COORDS_ARB
, "GL_MAX_TEXTURE_COORDS_ARB" },
187 { GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" },
194 #if defined(GL_ARB_vertex_shader)
195 if (target
== GL_VERTEX_SHADER_ARB
) {
196 printf(" GL_VERTEX_SHADER_ARB:\n");
197 for (i
= 0; vertex_limits
[i
].token
; i
++) {
198 glGetIntegerv(vertex_limits
[i
].token
, max
);
199 if (glGetError() == GL_NO_ERROR
) {
200 printf(" %s = %d\n", vertex_limits
[i
].name
, max
[0]);
205 #if defined(GL_ARB_fragment_shader)
206 if (target
== GL_FRAGMENT_SHADER_ARB
) {
207 printf(" GL_FRAGMENT_SHADER_ARB:\n");
208 for (i
= 0; fragment_limits
[i
].token
; i
++) {
209 glGetIntegerv(fragment_limits
[i
].token
, max
);
210 if (glGetError() == GL_NO_ERROR
) {
211 printf(" %s = %d\n", fragment_limits
[i
].name
, max
[0]);
220 * Print interesting OpenGL implementation limits.
223 print_limits(const char *extensions
)
230 static const struct token_name limits
[] = {
231 { 1, GL_MAX_ATTRIB_STACK_DEPTH
, "GL_MAX_ATTRIB_STACK_DEPTH" },
232 { 1, GL_MAX_CLIENT_ATTRIB_STACK_DEPTH
, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH" },
233 { 1, GL_MAX_CLIP_PLANES
, "GL_MAX_CLIP_PLANES" },
234 { 1, GL_MAX_COLOR_MATRIX_STACK_DEPTH
, "GL_MAX_COLOR_MATRIX_STACK_DEPTH" },
235 { 1, GL_MAX_ELEMENTS_VERTICES
, "GL_MAX_ELEMENTS_VERTICES" },
236 { 1, GL_MAX_ELEMENTS_INDICES
, "GL_MAX_ELEMENTS_INDICES" },
237 { 1, GL_MAX_EVAL_ORDER
, "GL_MAX_EVAL_ORDER" },
238 { 1, GL_MAX_LIGHTS
, "GL_MAX_LIGHTS" },
239 { 1, GL_MAX_LIST_NESTING
, "GL_MAX_LIST_NESTING" },
240 { 1, GL_MAX_MODELVIEW_STACK_DEPTH
, "GL_MAX_MODELVIEW_STACK_DEPTH" },
241 { 1, GL_MAX_NAME_STACK_DEPTH
, "GL_MAX_NAME_STACK_DEPTH" },
242 { 1, GL_MAX_PIXEL_MAP_TABLE
, "GL_MAX_PIXEL_MAP_TABLE" },
243 { 1, GL_MAX_PROJECTION_STACK_DEPTH
, "GL_MAX_PROJECTION_STACK_DEPTH" },
244 { 1, GL_MAX_TEXTURE_STACK_DEPTH
, "GL_MAX_TEXTURE_STACK_DEPTH" },
245 { 1, GL_MAX_TEXTURE_SIZE
, "GL_MAX_TEXTURE_SIZE" },
246 { 1, GL_MAX_3D_TEXTURE_SIZE
, "GL_MAX_3D_TEXTURE_SIZE" },
247 { 2, GL_MAX_VIEWPORT_DIMS
, "GL_MAX_VIEWPORT_DIMS" },
248 { 2, GL_ALIASED_LINE_WIDTH_RANGE
, "GL_ALIASED_LINE_WIDTH_RANGE" },
249 { 2, GL_SMOOTH_LINE_WIDTH_RANGE
, "GL_SMOOTH_LINE_WIDTH_RANGE" },
250 { 2, GL_ALIASED_POINT_SIZE_RANGE
, "GL_ALIASED_POINT_SIZE_RANGE" },
251 { 2, GL_SMOOTH_POINT_SIZE_RANGE
, "GL_SMOOTH_POINT_SIZE_RANGE" },
252 #if defined(GL_ARB_texture_cube_map)
253 { 1, GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
, "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB" },
255 #if defined(GLX_NV_texture_rectangle)
256 { 1, GL_MAX_RECTANGLE_TEXTURE_SIZE_NV
, "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV" },
258 #if defined(GL_ARB_texture_compression)
259 { 1, GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
, "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB" },
261 #if defined(GL_ARB_multitexture)
262 { 1, GL_MAX_TEXTURE_UNITS_ARB
, "GL_MAX_TEXTURE_UNITS_ARB" },
264 #if defined(GL_EXT_texture_lod_bias)
265 { 1, GL_MAX_TEXTURE_LOD_BIAS_EXT
, "GL_MAX_TEXTURE_LOD_BIAS_EXT" },
267 #if defined(GL_EXT_texture_filter_anisotropic)
268 { 1, GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT" },
270 #if defined(GL_ARB_draw_buffers)
271 { 1, GL_MAX_DRAW_BUFFERS_ARB
, "GL_MAX_DRAW_BUFFERS_ARB" },
273 { 0, (GLenum
) 0, NULL
}
277 printf("OpenGL limits:\n");
278 for (i
= 0; limits
[i
].count
; i
++) {
279 glGetIntegerv(limits
[i
].token
, max
);
280 if (glGetError() == GL_NO_ERROR
) {
281 if (limits
[i
].count
== 1)
282 printf(" %s = %d\n", limits
[i
].name
, max
[0]);
283 else /* XXX fix if we ever query something with more than 2 values */
284 printf(" %s = %d, %d\n", limits
[i
].name
, max
[0], max
[1]);
288 #if defined(GL_EXT_convolution)
290 PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC glGetConvolutionParameterivEXT_func
=
291 (PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC
)wglGetProcAddress("glGetConvolutionParameterivEXT");
292 if(glGetConvolutionParameterivEXT_func
) {
293 /* these don't fit into the above mechanism, unfortunately */
294 glGetConvolutionParameterivEXT_func(GL_CONVOLUTION_2D
, GL_MAX_CONVOLUTION_WIDTH
, max
);
295 glGetConvolutionParameterivEXT_func(GL_CONVOLUTION_2D
, GL_MAX_CONVOLUTION_HEIGHT
, max
+1);
296 if (glGetError() == GL_NONE
) {
297 printf(" GL_MAX_CONVOLUTION_WIDTH/HEIGHT = %d, %d\n", max
[0], max
[1]);
303 #if defined(GL_ARB_vertex_program)
304 if (strstr(extensions
, "GL_ARB_vertex_program")) {
305 print_program_limits(GL_VERTEX_PROGRAM_ARB
);
308 #if defined(GL_ARB_fragment_program)
309 if (strstr(extensions
, "GL_ARB_fragment_program")) {
310 print_program_limits(GL_FRAGMENT_PROGRAM_ARB
);
313 #if defined(GL_ARB_vertex_shader)
314 if (strstr(extensions
, "GL_ARB_vertex_shader")) {
315 print_shader_limits(GL_VERTEX_SHADER_ARB
);
318 #if defined(GL_ARB_fragment_shader)
319 if (strstr(extensions
, "GL_ARB_fragment_shader")) {
320 print_shader_limits(GL_FRAGMENT_SHADER_ARB
);
326 static LRESULT CALLBACK
337 return DefWindowProc(hWnd
, uMsg
, wParam
, lParam
);
345 print_screen_info(HDC _hdc
, GLboolean limits
)
352 PIXELFORMATDESCRIPTOR pfd
;
354 memset(&wc
, 0, sizeof wc
);
355 wc
.hbrBackground
= (HBRUSH
) (COLOR_BTNFACE
+ 1);
356 wc
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
357 wc
.hIcon
= LoadIcon(NULL
, IDI_APPLICATION
);
358 wc
.lpfnWndProc
= WndProc
;
359 wc
.lpszClassName
= "wglinfo";
360 wc
.style
= CS_OWNDC
| CS_HREDRAW
| CS_VREDRAW
;
363 win
= CreateWindowEx(0,
366 WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
,
376 fprintf(stderr
, "Couldn't create window");
382 fprintf(stderr
, "Couldn't obtain HDC");
390 pfd
.dwFlags
= PFD_DRAW_TO_WINDOW
| PFD_SUPPORT_OPENGL
;
391 pfd
.iLayerType
= PFD_MAIN_PLANE
;
392 pfd
.iPixelType
= PFD_TYPE_RGBA
;
393 pfd
.nSize
= sizeof(pfd
);
396 visinfo
= ChoosePixelFormat(hdc
, &pfd
);
398 pfd
.dwFlags
|= PFD_DOUBLEBUFFER
;
399 visinfo
= ChoosePixelFormat(hdc
, &pfd
);
403 fprintf(stderr
, "Error: couldn't find RGB WGL visual\n");
407 SetPixelFormat(hdc
, visinfo
, &pfd
);
408 ctx
= wglCreateContext(hdc
);
410 fprintf(stderr
, "Error: wglCreateContext failed\n");
414 if (wglMakeCurrent(hdc
, ctx
)) {
415 #if defined(WGL_ARB_extensions_string)
416 PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB_func
=
417 (PFNWGLGETEXTENSIONSSTRINGARBPROC
)wglGetProcAddress("wglGetExtensionsStringARB");
419 const char *glVendor
= (const char *) glGetString(GL_VENDOR
);
420 const char *glRenderer
= (const char *) glGetString(GL_RENDERER
);
421 const char *glVersion
= (const char *) glGetString(GL_VERSION
);
422 const char *glExtensions
= (const char *) glGetString(GL_EXTENSIONS
);
424 #if defined(WGL_ARB_extensions_string)
425 if(wglGetExtensionsStringARB_func
) {
426 const char *wglExtensions
= wglGetExtensionsStringARB_func(hdc
);
428 printf("WGL extensions:\n");
429 print_extension_list(wglExtensions
);
433 printf("OpenGL vendor string: %s\n", glVendor
);
434 printf("OpenGL renderer string: %s\n", glRenderer
);
435 printf("OpenGL version string: %s\n", glVersion
);
436 #ifdef GL_VERSION_2_0
437 if (glVersion
[0] >= '2' && glVersion
[1] == '.') {
438 char *v
= (char *) glGetString(GL_SHADING_LANGUAGE_VERSION
);
439 printf("OpenGL shading language version string: %s\n", v
);
443 printf("OpenGL extensions:\n");
444 print_extension_list(glExtensions
);
446 print_limits(glExtensions
);
449 fprintf(stderr
, "Error: wglMakeCurrent failed\n");
457 visual_render_type_name(BYTE iPixelType
)
459 switch (iPixelType
) {
462 case PFD_TYPE_COLORINDEX
:
470 print_visual_attribs_verbose(int iPixelFormat
, LPPIXELFORMATDESCRIPTOR ppfd
)
472 printf("Visual ID: %x generic=%d native=%d\n",
474 ppfd
->dwFlags
& PFD_GENERIC_FORMAT
? 1 : 0,
475 ppfd
->dwFlags
& PFD_DRAW_TO_WINDOW
? 1 : 0);
476 printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
477 0 /* ppfd->bufferSize */, 0 /* ppfd->level */,
478 visual_render_type_name(ppfd
->iPixelType
),
479 ppfd
->dwFlags
& PFD_DOUBLEBUFFER
? 1 : 0,
480 ppfd
->dwFlags
& PFD_STEREO
? 1 : 0);
481 printf(" rgba: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
482 ppfd
->cRedBits
, ppfd
->cGreenBits
,
483 ppfd
->cBlueBits
, ppfd
->cAlphaBits
);
484 printf(" cAuxBuffers=%d cDepthBits=%d cStencilBits=%d\n",
485 ppfd
->cAuxBuffers
, ppfd
->cDepthBits
, ppfd
->cStencilBits
);
486 printf(" accum: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
487 ppfd
->cAccumRedBits
, ppfd
->cAccumGreenBits
,
488 ppfd
->cAccumBlueBits
, ppfd
->cAccumAlphaBits
);
489 printf(" multiSample=%d multiSampleBuffers=%d\n",
490 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */);
495 print_visual_attribs_short_header(void)
497 printf(" visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav\n");
498 printf(" id gen nat sp sz l ci b ro r g b a bf th cl r g b a ns b eat\n");
499 printf("-----------------------------------------------------------------------\n");
504 print_visual_attribs_short(int iPixelFormat
, LPPIXELFORMATDESCRIPTOR ppfd
)
506 char *caveat
= "None";
508 printf("0x%02x %2d %2d %2d %2d %2d %c%c %c %c %2d %2d %2d %2d %2d %2d %2d",
510 ppfd
->dwFlags
& PFD_GENERIC_FORMAT
? 1 : 0,
511 ppfd
->dwFlags
& PFD_DRAW_TO_WINDOW
? 1 : 0,
513 0 /* ppfd->bufferSize */,
515 ppfd
->iPixelType
== PFD_TYPE_RGBA
? 'r' : ' ',
516 ppfd
->iPixelType
== PFD_TYPE_COLORINDEX
? 'c' : ' ',
517 ppfd
->dwFlags
& PFD_DOUBLEBUFFER
? 'y' : '.',
518 ppfd
->dwFlags
& PFD_STEREO
? 'y' : '.',
519 ppfd
->cRedBits
, ppfd
->cGreenBits
,
520 ppfd
->cBlueBits
, ppfd
->cAlphaBits
,
526 printf(" %2d %2d %2d %2d %2d %1d %s\n",
527 ppfd
->cAccumRedBits
, ppfd
->cAccumGreenBits
,
528 ppfd
->cAccumBlueBits
, ppfd
->cAccumAlphaBits
,
529 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */,
536 print_visual_attribs_long_header(void)
538 printf("Vis Vis Visual Trans buff lev render DB ste r g b a aux dep ste accum buffers MS MS\n");
539 printf(" ID Depth Type parent size el type reo sz sz sz sz buf th ncl r g b a num bufs\n");
540 printf("----------------------------------------------------------------------------------------------------\n");
545 print_visual_attribs_long(int iPixelFormat
, LPPIXELFORMATDESCRIPTOR ppfd
)
547 printf("0x%2x %2d %11d %2d %2d %2d %4s %3d %3d %3d %3d %3d %3d",
549 ppfd
->dwFlags
& PFD_GENERIC_FORMAT
? 1 : 0,
550 ppfd
->dwFlags
& PFD_DRAW_TO_WINDOW
? 1 : 0,
552 0 /* ppfd->bufferSize */,
554 visual_render_type_name(ppfd
->iPixelType
),
555 ppfd
->dwFlags
& PFD_DOUBLEBUFFER
? 1 : 0,
556 ppfd
->dwFlags
& PFD_STEREO
? 1 : 0,
557 ppfd
->cRedBits
, ppfd
->cGreenBits
,
558 ppfd
->cBlueBits
, ppfd
->cAlphaBits
561 printf(" %3d %4d %2d %3d %3d %3d %3d %2d %2d\n",
565 ppfd
->cAccumRedBits
, ppfd
->cAccumGreenBits
,
566 ppfd
->cAccumBlueBits
, ppfd
->cAccumAlphaBits
,
567 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */
573 print_visual_info(HDC hdc
, InfoMode mode
)
575 PIXELFORMATDESCRIPTOR pfd
;
576 int numVisuals
, numWglVisuals
;
579 numVisuals
= DescribePixelFormat(hdc
, 1, sizeof(PIXELFORMATDESCRIPTOR
), NULL
);
584 for (i
= 0; i
< numVisuals
; i
++) {
585 if(!DescribePixelFormat(hdc
, i
, sizeof(PIXELFORMATDESCRIPTOR
), &pfd
))
588 //if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
594 printf("%d WGL Visuals\n", numWglVisuals
);
597 print_visual_attribs_short_header();
598 else if (mode
== Wide
)
599 print_visual_attribs_long_header();
601 for (i
= 0; i
< numVisuals
; i
++) {
602 if(!DescribePixelFormat(hdc
, i
, sizeof(PIXELFORMATDESCRIPTOR
), &pfd
))
605 //if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
609 print_visual_attribs_verbose(i
, &pfd
);
610 else if (mode
== Normal
)
611 print_visual_attribs_short(i
, &pfd
);
612 else if (mode
== Wide
)
613 print_visual_attribs_long(i
, &pfd
);
620 * Examine all visuals to find the so-called best one.
621 * We prefer deepest RGBA buffer with depth, stencil and accum
622 * that has no caveats.
625 find_best_visual(HDC hdc
)
628 XVisualInfo theTemplate
;
629 XVisualInfo
*visuals
;
633 struct visual_attribs bestVis
;
635 /* get list of all visuals on this screen */
636 theTemplate
.screen
= scrnum
;
637 mask
= VisualScreenMask
;
638 visuals
= XGetVisualInfo(hdc
, mask
, &theTemplate
, &numVisuals
);
640 /* init bestVis with first visual info */
641 get_visual_attribs(hdc
, &visuals
[0], &bestVis
);
643 /* try to find a "better" visual */
644 for (i
= 1; i
< numVisuals
; i
++) {
645 struct visual_attribs vis
;
647 get_visual_attribs(hdc
, &visuals
[i
], &vis
);
649 /* always skip visuals with caveats */
650 if (vis
.visualCaveat
!= GLX_NONE_EXT
)
653 /* see if this vis is better than bestVis */
654 if ((!bestVis
.supportsGL
&& vis
.supportsGL
) ||
655 (bestVis
.visualCaveat
!= GLX_NONE_EXT
) ||
656 (bestVis
.iPixelType
!= vis
.iPixelType
) ||
657 (!bestVis
.doubleBuffer
&& vis
.doubleBuffer
) ||
658 (bestVis
.cRedBits
< vis
.cRedBits
) ||
659 (bestVis
.cGreenBits
< vis
.cGreenBits
) ||
660 (bestVis
.cBlueBits
< vis
.cBlueBits
) ||
661 (bestVis
.cAlphaBits
< vis
.cAlphaBits
) ||
662 (bestVis
.cDepthBits
< vis
.cDepthBits
) ||
663 (bestVis
.cStencilBits
< vis
.cStencilBits
) ||
664 (bestVis
.cAccumRedBits
< vis
.cAccumRedBits
)) {
665 /* found a better visual */
680 printf("Usage: glxinfo [-v] [-t] [-h] [-i] [-b] [-display <dname>]\n");
681 printf("\t-v: Print visuals info in verbose form.\n");
682 printf("\t-t: Print verbose table.\n");
683 printf("\t-h: This information.\n");
684 printf("\t-b: Find the 'best' visual and print it's number.\n");
685 printf("\t-l: Print interesting OpenGL limits.\n");
690 main(int argc
, char *argv
[])
693 InfoMode mode
= Normal
;
694 GLboolean findBest
= GL_FALSE
;
695 GLboolean limits
= GL_FALSE
;
698 for (i
= 1; i
< argc
; i
++) {
699 if (strcmp(argv
[i
], "-t") == 0) {
702 else if (strcmp(argv
[i
], "-v") == 0) {
705 else if (strcmp(argv
[i
], "-b") == 0) {
708 else if (strcmp(argv
[i
], "-l") == 0) {
711 else if (strcmp(argv
[i
], "-h") == 0) {
716 printf("Unknown option `%s'\n", argv
[i
]);
722 hdc
= CreateDC(TEXT("DISPLAY"), NULL
, NULL
, NULL
);
726 b
= find_best_visual(hdc
);
730 print_screen_info(hdc
, limits
);
732 print_visual_info(hdc
, mode
);