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
)
351 int width
= 100, height
= 100;
353 PIXELFORMATDESCRIPTOR pfd
;
355 memset(&wc
, 0, sizeof wc
);
356 wc
.hbrBackground
= (HBRUSH
) (COLOR_BTNFACE
+ 1);
357 wc
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
358 wc
.hIcon
= LoadIcon(NULL
, IDI_APPLICATION
);
359 wc
.lpfnWndProc
= WndProc
;
360 wc
.lpszClassName
= "wglinfo";
361 wc
.style
= CS_OWNDC
| CS_HREDRAW
| CS_VREDRAW
;
364 win
= CreateWindowEx(0,
367 WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
,
377 fprintf(stderr
, "Couldn't create window");
383 fprintf(stderr
, "Couldn't obtain HDC");
391 pfd
.dwFlags
= PFD_DRAW_TO_WINDOW
| PFD_SUPPORT_OPENGL
;
392 pfd
.iLayerType
= PFD_MAIN_PLANE
;
393 pfd
.iPixelType
= PFD_TYPE_RGBA
;
394 pfd
.nSize
= sizeof(pfd
);
397 visinfo
= ChoosePixelFormat(hdc
, &pfd
);
399 pfd
.dwFlags
|= PFD_DOUBLEBUFFER
;
400 visinfo
= ChoosePixelFormat(hdc
, &pfd
);
404 fprintf(stderr
, "Error: couldn't find RGB WGL visual\n");
408 SetPixelFormat(hdc
, visinfo
, &pfd
);
409 ctx
= wglCreateContext(hdc
);
411 fprintf(stderr
, "Error: wglCreateContext failed\n");
415 if (wglMakeCurrent(hdc
, ctx
)) {
416 #if defined(WGL_ARB_extensions_string)
417 PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB_func
=
418 (PFNWGLGETEXTENSIONSSTRINGARBPROC
)wglGetProcAddress("wglGetExtensionsStringARB");
420 const char *glVendor
= (const char *) glGetString(GL_VENDOR
);
421 const char *glRenderer
= (const char *) glGetString(GL_RENDERER
);
422 const char *glVersion
= (const char *) glGetString(GL_VERSION
);
423 const char *glExtensions
= (const char *) glGetString(GL_EXTENSIONS
);
425 #if defined(WGL_ARB_extensions_string)
426 if(wglGetExtensionsStringARB_func
) {
427 const char *wglExtensions
= wglGetExtensionsStringARB_func(hdc
);
429 printf("WGL extensions:\n");
430 print_extension_list(wglExtensions
);
434 printf("OpenGL vendor string: %s\n", glVendor
);
435 printf("OpenGL renderer string: %s\n", glRenderer
);
436 printf("OpenGL version string: %s\n", glVersion
);
437 #ifdef GL_VERSION_2_0
438 if (glVersion
[0] >= '2' && glVersion
[1] == '.') {
439 char *v
= (char *) glGetString(GL_SHADING_LANGUAGE_VERSION
);
440 printf("OpenGL shading language version string: %s\n", v
);
444 printf("OpenGL extensions:\n");
445 print_extension_list(glExtensions
);
447 print_limits(glExtensions
);
450 fprintf(stderr
, "Error: wglMakeCurrent failed\n");
458 visual_render_type_name(BYTE iPixelType
)
460 switch (iPixelType
) {
463 case PFD_TYPE_COLORINDEX
:
471 print_visual_attribs_verbose(int iPixelFormat
, LPPIXELFORMATDESCRIPTOR ppfd
)
473 printf("Visual ID: %x generic=%d native=%d\n",
475 ppfd
->dwFlags
& PFD_GENERIC_FORMAT
? 1 : 0,
476 ppfd
->dwFlags
& PFD_DRAW_TO_WINDOW
? 1 : 0);
477 printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
478 0 /* ppfd->bufferSize */, 0 /* ppfd->level */,
479 visual_render_type_name(ppfd
->dwFlags
),
480 ppfd
->dwFlags
& PFD_DOUBLEBUFFER
? 1 : 0,
481 ppfd
->dwFlags
& PFD_STEREO
? 1 : 0);
482 printf(" rgba: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
483 ppfd
->cRedBits
, ppfd
->cGreenBits
,
484 ppfd
->cBlueBits
, ppfd
->cAlphaBits
);
485 printf(" cAuxBuffers=%d cDepthBits=%d cStencilBits=%d\n",
486 ppfd
->cAuxBuffers
, ppfd
->cDepthBits
, ppfd
->cStencilBits
);
487 printf(" accum: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
488 ppfd
->cAccumRedBits
, ppfd
->cAccumGreenBits
,
489 ppfd
->cAccumBlueBits
, ppfd
->cAccumAlphaBits
);
490 printf(" multiSample=%d multiSampleBuffers=%d\n",
491 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */);
496 print_visual_attribs_short_header(void)
498 printf(" visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav\n");
499 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");
500 printf("-----------------------------------------------------------------------\n");
505 print_visual_attribs_short(int iPixelFormat
, LPPIXELFORMATDESCRIPTOR ppfd
)
507 char *caveat
= "None";
509 printf("0x%02x %2d %2d %2d %2d %2d %c%c %c %c %2d %2d %2d %2d %2d %2d %2d",
511 ppfd
->dwFlags
& PFD_GENERIC_FORMAT
? 1 : 0,
512 ppfd
->dwFlags
& PFD_DRAW_TO_WINDOW
? 1 : 0,
514 0 /* ppfd->bufferSize */,
516 ppfd
->iPixelType
== PFD_TYPE_RGBA
? 'r' : ' ',
517 ppfd
->iPixelType
== PFD_TYPE_COLORINDEX
? 'c' : ' ',
518 ppfd
->dwFlags
& PFD_DOUBLEBUFFER
? 'y' : '.',
519 ppfd
->dwFlags
& PFD_STEREO
? 'y' : '.',
520 ppfd
->cRedBits
, ppfd
->cGreenBits
,
521 ppfd
->cBlueBits
, ppfd
->cAlphaBits
,
527 printf(" %2d %2d %2d %2d %2d %1d %s\n",
528 ppfd
->cAccumRedBits
, ppfd
->cAccumGreenBits
,
529 ppfd
->cAccumBlueBits
, ppfd
->cAccumAlphaBits
,
530 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */,
537 print_visual_attribs_long_header(void)
539 printf("Vis Vis Visual Trans buff lev render DB ste r g b a aux dep ste accum buffers MS MS\n");
540 printf(" ID Depth Type parent size el type reo sz sz sz sz buf th ncl r g b a num bufs\n");
541 printf("----------------------------------------------------------------------------------------------------\n");
546 print_visual_attribs_long(int iPixelFormat
, LPPIXELFORMATDESCRIPTOR ppfd
)
548 printf("0x%2x %2d %11d %2d %2d %2d %4s %3d %3d %3d %3d %3d %3d",
550 ppfd
->dwFlags
& PFD_GENERIC_FORMAT
? 1 : 0,
551 ppfd
->dwFlags
& PFD_DRAW_TO_WINDOW
? 1 : 0,
553 0 /* ppfd->bufferSize */,
555 visual_render_type_name(ppfd
->iPixelType
),
556 ppfd
->dwFlags
& PFD_DOUBLEBUFFER
? 1 : 0,
557 ppfd
->dwFlags
& PFD_STEREO
? 1 : 0,
558 ppfd
->cRedBits
, ppfd
->cGreenBits
,
559 ppfd
->cBlueBits
, ppfd
->cAlphaBits
562 printf(" %3d %4d %2d %3d %3d %3d %3d %2d %2d\n",
566 ppfd
->cAccumRedBits
, ppfd
->cAccumGreenBits
,
567 ppfd
->cAccumBlueBits
, ppfd
->cAccumAlphaBits
,
568 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */
574 print_visual_info(HDC hdc
, InfoMode mode
)
576 PIXELFORMATDESCRIPTOR pfd
;
577 int numVisuals
, numWglVisuals
;
580 numVisuals
= DescribePixelFormat(hdc
, 1, sizeof(PIXELFORMATDESCRIPTOR
), NULL
);
585 for (i
= 0; i
< numVisuals
; i
++) {
586 if(!DescribePixelFormat(hdc
, i
, sizeof(PIXELFORMATDESCRIPTOR
), &pfd
))
589 //if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
595 printf("%d WGL Visuals\n", numWglVisuals
);
598 print_visual_attribs_short_header();
599 else if (mode
== Wide
)
600 print_visual_attribs_long_header();
602 for (i
= 0; i
< numVisuals
; i
++) {
603 if(!DescribePixelFormat(hdc
, i
, sizeof(PIXELFORMATDESCRIPTOR
), &pfd
))
606 //if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
610 print_visual_attribs_verbose(i
, &pfd
);
611 else if (mode
== Normal
)
612 print_visual_attribs_short(i
, &pfd
);
613 else if (mode
== Wide
)
614 print_visual_attribs_long(i
, &pfd
);
621 * Examine all visuals to find the so-called best one.
622 * We prefer deepest RGBA buffer with depth, stencil and accum
623 * that has no caveats.
626 find_best_visual(HDC hdc
)
629 XVisualInfo theTemplate
;
630 XVisualInfo
*visuals
;
634 struct visual_attribs bestVis
;
636 /* get list of all visuals on this screen */
637 theTemplate
.screen
= scrnum
;
638 mask
= VisualScreenMask
;
639 visuals
= XGetVisualInfo(hdc
, mask
, &theTemplate
, &numVisuals
);
641 /* init bestVis with first visual info */
642 get_visual_attribs(hdc
, &visuals
[0], &bestVis
);
644 /* try to find a "better" visual */
645 for (i
= 1; i
< numVisuals
; i
++) {
646 struct visual_attribs vis
;
648 get_visual_attribs(hdc
, &visuals
[i
], &vis
);
650 /* always skip visuals with caveats */
651 if (vis
.visualCaveat
!= GLX_NONE_EXT
)
654 /* see if this vis is better than bestVis */
655 if ((!bestVis
.supportsGL
&& vis
.supportsGL
) ||
656 (bestVis
.visualCaveat
!= GLX_NONE_EXT
) ||
657 (bestVis
.iPixelType
!= vis
.iPixelType
) ||
658 (!bestVis
.doubleBuffer
&& vis
.doubleBuffer
) ||
659 (bestVis
.cRedBits
< vis
.cRedBits
) ||
660 (bestVis
.cGreenBits
< vis
.cGreenBits
) ||
661 (bestVis
.cBlueBits
< vis
.cBlueBits
) ||
662 (bestVis
.cAlphaBits
< vis
.cAlphaBits
) ||
663 (bestVis
.cDepthBits
< vis
.cDepthBits
) ||
664 (bestVis
.cStencilBits
< vis
.cStencilBits
) ||
665 (bestVis
.cAccumRedBits
< vis
.cAccumRedBits
)) {
666 /* found a better visual */
681 printf("Usage: glxinfo [-v] [-t] [-h] [-i] [-b] [-display <dname>]\n");
682 printf("\t-v: Print visuals info in verbose form.\n");
683 printf("\t-t: Print verbose table.\n");
684 printf("\t-h: This information.\n");
685 printf("\t-b: Find the 'best' visual and print it's number.\n");
686 printf("\t-l: Print interesting OpenGL limits.\n");
691 main(int argc
, char *argv
[])
694 InfoMode mode
= Normal
;
695 GLboolean findBest
= GL_FALSE
;
696 GLboolean limits
= GL_FALSE
;
699 for (i
= 1; i
< argc
; i
++) {
700 if (strcmp(argv
[i
], "-t") == 0) {
703 else if (strcmp(argv
[i
], "-v") == 0) {
706 else if (strcmp(argv
[i
], "-b") == 0) {
709 else if (strcmp(argv
[i
], "-l") == 0) {
712 else if (strcmp(argv
[i
], "-h") == 0) {
717 printf("Unknown option `%s'\n", argv
[i
]);
723 hdc
= CreateDC(TEXT("DISPLAY"), NULL
, NULL
, NULL
);
727 b
= find_best_visual(hdc
);
731 print_screen_info(hdc
, limits
);
733 print_visual_info(hdc
, mode
);