Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 1 | /* |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 2 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 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. |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 23 | /* |
| 24 | * This program is a work-alike of the IRIX glxinfo program. |
| 25 | * Command line options: |
| 26 | * -t print wide table |
| 27 | * -v print verbose information |
| 28 | * -display DisplayName specify the X display to interogate |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 29 | * -b only print ID of "best" visual on screen 0 |
Brian Paul | 28bc6cb | 2002-09-06 03:47:34 +0000 | [diff] [blame] | 30 | * -i use indirect rendering connection only |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 31 | * -l print interesting OpenGL limits (added 5 Sep 2002) |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 32 | * |
| 33 | * Brian Paul 26 January 2000 |
| 34 | */ |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 35 | |
Brian Paul | 2ca741a | 2006-05-15 15:35:38 +0000 | [diff] [blame] | 36 | #define GLX_GLXEXT_PROTOTYPES |
| 37 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 38 | #include <X11/Xlib.h> |
| 39 | #include <X11/Xutil.h> |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 40 | #include <GL/gl.h> |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 41 | #include <GL/glx.h> |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 42 | #include <stdio.h> |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 43 | #include <string.h> |
Brian Paul | 373aea1 | 2001-04-02 22:45:07 +0000 | [diff] [blame] | 44 | #include <stdlib.h> |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 45 | |
| 46 | |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 47 | #ifndef GLX_NONE_EXT |
| 48 | #define GLX_NONE_EXT 0x8000 |
| 49 | #endif |
| 50 | |
Brian Paul | 45c5698 | 2002-10-14 13:57:23 +0000 | [diff] [blame] | 51 | #ifndef GLX_TRANSPARENT_RGB |
| 52 | #define GLX_TRANSPARENT_RGB 0x8008 |
| 53 | #endif |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 54 | |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 55 | #ifndef GLX_RGBA_BIT |
| 56 | #define GLX_RGBA_BIT 0x00000001 |
| 57 | #endif |
| 58 | |
| 59 | #ifndef GLX_COLOR_INDEX_BIT |
| 60 | #define GLX_COLOR_INDEX_BIT 0x00000002 |
| 61 | #endif |
Brian Paul | 2ca741a | 2006-05-15 15:35:38 +0000 | [diff] [blame] | 62 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 63 | typedef enum |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 64 | { |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 65 | Normal, |
| 66 | Wide, |
| 67 | Verbose |
| 68 | } InfoMode; |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 69 | |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 70 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 71 | struct visual_attribs |
| 72 | { |
| 73 | /* X visual attribs */ |
| 74 | int id; |
| 75 | int klass; |
| 76 | int depth; |
| 77 | int redMask, greenMask, blueMask; |
| 78 | int colormapSize; |
| 79 | int bitsPerRGB; |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 80 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 81 | /* GL visual attribs */ |
| 82 | int supportsGL; |
Brian Paul | 45c5698 | 2002-10-14 13:57:23 +0000 | [diff] [blame] | 83 | int transparentType; |
| 84 | int transparentRedValue; |
| 85 | int transparentGreenValue; |
| 86 | int transparentBlueValue; |
| 87 | int transparentAlphaValue; |
| 88 | int transparentIndexValue; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 89 | int bufferSize; |
| 90 | int level; |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 91 | int render_type; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 92 | int doubleBuffer; |
| 93 | int stereo; |
| 94 | int auxBuffers; |
| 95 | int redSize, greenSize, blueSize, alphaSize; |
| 96 | int depthSize; |
| 97 | int stencilSize; |
| 98 | int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize; |
| 99 | int numSamples, numMultisample; |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 100 | int visualCaveat; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | |
| 104 | /* |
| 105 | * Print a list of extensions, with word-wrapping. |
| 106 | */ |
| 107 | static void |
| 108 | print_extension_list(const char *ext) |
| 109 | { |
| 110 | const char *indentString = " "; |
| 111 | const int indent = 4; |
| 112 | const int max = 79; |
| 113 | int width, i, j; |
| 114 | |
| 115 | if (!ext || !ext[0]) |
| 116 | return; |
| 117 | |
| 118 | width = indent; |
| 119 | printf(indentString); |
| 120 | i = j = 0; |
| 121 | while (1) { |
| 122 | if (ext[j] == ' ' || ext[j] == 0) { |
| 123 | /* found end of an extension name */ |
| 124 | const int len = j - i; |
| 125 | if (width + len > max) { |
| 126 | /* start a new line */ |
| 127 | printf("\n"); |
| 128 | width = indent; |
| 129 | printf(indentString); |
| 130 | } |
| 131 | /* print the extension name between ext[i] and ext[j] */ |
| 132 | while (i < j) { |
| 133 | printf("%c", ext[i]); |
| 134 | i++; |
| 135 | } |
| 136 | /* either we're all done, or we'll continue with next extension */ |
| 137 | width += len + 1; |
| 138 | if (ext[j] == 0) { |
| 139 | break; |
| 140 | } |
| 141 | else { |
| 142 | i++; |
| 143 | j++; |
Brian Paul | 7ac4350 | 2000-02-23 22:50:35 +0000 | [diff] [blame] | 144 | if (ext[j] == 0) |
| 145 | break; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 146 | printf(", "); |
| 147 | width += 2; |
| 148 | } |
| 149 | } |
| 150 | j++; |
| 151 | } |
| 152 | printf("\n"); |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 156 | static void |
Brian Paul | 373aea1 | 2001-04-02 22:45:07 +0000 | [diff] [blame] | 157 | print_display_info(Display *dpy) |
| 158 | { |
| 159 | printf("name of display: %s\n", DisplayString(dpy)); |
| 160 | } |
| 161 | |
| 162 | |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 163 | /** |
| 164 | * Print interesting limits for vertex/fragment programs. |
| 165 | */ |
Brian Paul | 373aea1 | 2001-04-02 22:45:07 +0000 | [diff] [blame] | 166 | static void |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 167 | print_program_limits(GLenum target) |
| 168 | { |
| 169 | #if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program) |
| 170 | struct token_name { |
| 171 | GLenum token; |
| 172 | const char *name; |
| 173 | }; |
| 174 | static const struct token_name limits[] = { |
| 175 | { GL_MAX_PROGRAM_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_INSTRUCTIONS_ARB" }, |
| 176 | { GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" }, |
| 177 | { GL_MAX_PROGRAM_TEMPORARIES_ARB, "GL_MAX_PROGRAM_TEMPORARIES_ARB" }, |
| 178 | { GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" }, |
| 179 | { GL_MAX_PROGRAM_PARAMETERS_ARB, "GL_MAX_PROGRAM_PARAMETERS_ARB" }, |
| 180 | { GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB" }, |
| 181 | { GL_MAX_PROGRAM_ATTRIBS_ARB, "GL_MAX_PROGRAM_ATTRIBS_ARB" }, |
| 182 | { GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB" }, |
| 183 | { GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB" }, |
| 184 | { GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" }, |
| 185 | { GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB" }, |
| 186 | { GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB" }, |
| 187 | { GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" }, |
| 188 | { GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" }, |
| 189 | { GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB" }, |
| 190 | { GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" }, |
| 191 | { GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" }, |
| 192 | { GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" }, |
| 193 | { (GLenum) 0, NULL } |
| 194 | }; |
| 195 | PFNGLGETPROGRAMIVARBPROC GetProgramivARB_func = (PFNGLGETPROGRAMIVARBPROC) |
| 196 | glXGetProcAddressARB((GLubyte *) "glGetProgramivARB"); |
| 197 | GLint max[1]; |
| 198 | int i; |
| 199 | |
| 200 | if (target == GL_VERTEX_PROGRAM_ARB) { |
| 201 | printf(" GL_VERTEX_PROGRAM_ARB:\n"); |
| 202 | } |
| 203 | else if (target == GL_FRAGMENT_PROGRAM_ARB) { |
| 204 | printf(" GL_FRAGMENT_PROGRAM_ARB:\n"); |
| 205 | } |
| 206 | else { |
| 207 | return; /* something's wrong */ |
| 208 | } |
| 209 | |
| 210 | for (i = 0; limits[i].token; i++) { |
| 211 | GetProgramivARB_func(target, limits[i].token, max); |
| 212 | if (glGetError() == GL_NO_ERROR) { |
| 213 | printf(" %s = %d\n", limits[i].name, max[0]); |
| 214 | } |
| 215 | } |
Brian Paul | 2ca741a | 2006-05-15 15:35:38 +0000 | [diff] [blame] | 216 | #endif /* GL_ARB_vertex_program / GL_ARB_fragment_program */ |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | |
| 220 | /** |
| 221 | * Print interesting limits for vertex/fragment shaders. |
| 222 | */ |
| 223 | static void |
| 224 | print_shader_limits(GLenum target) |
| 225 | { |
| 226 | struct token_name { |
| 227 | GLenum token; |
| 228 | const char *name; |
| 229 | }; |
| 230 | #if defined(GL_ARB_vertex_shader) |
| 231 | static const struct token_name vertex_limits[] = { |
| 232 | { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB" }, |
| 233 | { GL_MAX_VARYING_FLOATS_ARB, "GL_MAX_VARYING_FLOATS_ARB" }, |
| 234 | { GL_MAX_VERTEX_ATTRIBS_ARB, "GL_MAX_VERTEX_ATTRIBS_ARB" }, |
| 235 | { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, |
| 236 | { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" }, |
| 237 | { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" }, |
| 238 | { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" }, |
| 239 | { (GLenum) 0, NULL } |
| 240 | }; |
| 241 | #endif |
| 242 | #if defined(GL_ARB_fragment_shader) |
| 243 | static const struct token_name fragment_limits[] = { |
| 244 | { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" }, |
| 245 | { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" }, |
| 246 | { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, |
| 247 | { (GLenum) 0, NULL } |
| 248 | }; |
| 249 | #endif |
| 250 | GLint max[1]; |
| 251 | int i; |
| 252 | |
| 253 | #if defined(GL_ARB_vertex_shader) |
| 254 | if (target == GL_VERTEX_SHADER_ARB) { |
| 255 | printf(" GL_VERTEX_SHADER_ARB:\n"); |
| 256 | for (i = 0; vertex_limits[i].token; i++) { |
| 257 | glGetIntegerv(vertex_limits[i].token, max); |
| 258 | if (glGetError() == GL_NO_ERROR) { |
| 259 | printf(" %s = %d\n", vertex_limits[i].name, max[0]); |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | #endif |
| 264 | #if defined(GL_ARB_fragment_shader) |
| 265 | if (target == GL_FRAGMENT_SHADER_ARB) { |
| 266 | printf(" GL_FRAGMENT_SHADER_ARB:\n"); |
| 267 | for (i = 0; fragment_limits[i].token; i++) { |
| 268 | glGetIntegerv(fragment_limits[i].token, max); |
| 269 | if (glGetError() == GL_NO_ERROR) { |
| 270 | printf(" %s = %d\n", fragment_limits[i].name, max[0]); |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | #endif |
| 275 | } |
| 276 | |
| 277 | |
| 278 | /** |
| 279 | * Print interesting OpenGL implementation limits. |
| 280 | */ |
| 281 | static void |
| 282 | print_limits(const char *extensions) |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 283 | { |
| 284 | struct token_name { |
| 285 | GLuint count; |
| 286 | GLenum token; |
| 287 | const char *name; |
| 288 | }; |
| 289 | static const struct token_name limits[] = { |
| 290 | { 1, GL_MAX_ATTRIB_STACK_DEPTH, "GL_MAX_ATTRIB_STACK_DEPTH" }, |
| 291 | { 1, GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH" }, |
| 292 | { 1, GL_MAX_CLIP_PLANES, "GL_MAX_CLIP_PLANES" }, |
| 293 | { 1, GL_MAX_COLOR_MATRIX_STACK_DEPTH, "GL_MAX_COLOR_MATRIX_STACK_DEPTH" }, |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 294 | { 1, GL_MAX_ELEMENTS_VERTICES, "GL_MAX_ELEMENTS_VERTICES" }, |
| 295 | { 1, GL_MAX_ELEMENTS_INDICES, "GL_MAX_ELEMENTS_INDICES" }, |
| 296 | { 1, GL_MAX_EVAL_ORDER, "GL_MAX_EVAL_ORDER" }, |
| 297 | { 1, GL_MAX_LIGHTS, "GL_MAX_LIGHTS" }, |
| 298 | { 1, GL_MAX_LIST_NESTING, "GL_MAX_LIST_NESTING" }, |
| 299 | { 1, GL_MAX_MODELVIEW_STACK_DEPTH, "GL_MAX_MODELVIEW_STACK_DEPTH" }, |
| 300 | { 1, GL_MAX_NAME_STACK_DEPTH, "GL_MAX_NAME_STACK_DEPTH" }, |
| 301 | { 1, GL_MAX_PIXEL_MAP_TABLE, "GL_MAX_PIXEL_MAP_TABLE" }, |
| 302 | { 1, GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH" }, |
| 303 | { 1, GL_MAX_TEXTURE_STACK_DEPTH, "GL_MAX_TEXTURE_STACK_DEPTH" }, |
| 304 | { 1, GL_MAX_TEXTURE_SIZE, "GL_MAX_TEXTURE_SIZE" }, |
| 305 | { 1, GL_MAX_3D_TEXTURE_SIZE, "GL_MAX_3D_TEXTURE_SIZE" }, |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 306 | { 2, GL_MAX_VIEWPORT_DIMS, "GL_MAX_VIEWPORT_DIMS" }, |
| 307 | { 2, GL_ALIASED_LINE_WIDTH_RANGE, "GL_ALIASED_LINE_WIDTH_RANGE" }, |
| 308 | { 2, GL_SMOOTH_LINE_WIDTH_RANGE, "GL_SMOOTH_LINE_WIDTH_RANGE" }, |
| 309 | { 2, GL_ALIASED_POINT_SIZE_RANGE, "GL_ALIASED_POINT_SIZE_RANGE" }, |
| 310 | { 2, GL_SMOOTH_POINT_SIZE_RANGE, "GL_SMOOTH_POINT_SIZE_RANGE" }, |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 311 | #if defined(GL_ARB_texture_cube_map) |
| 312 | { 1, GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB" }, |
| 313 | #endif |
| 314 | #if defined(GLX_NV_texture_rectangle) |
| 315 | { 1, GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV" }, |
| 316 | #endif |
| 317 | #if defined(GL_ARB_texture_compression) |
| 318 | { 1, GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB" }, |
| 319 | #endif |
| 320 | #if defined(GL_ARB_multitexture) |
| 321 | { 1, GL_MAX_TEXTURE_UNITS_ARB, "GL_MAX_TEXTURE_UNITS_ARB" }, |
| 322 | #endif |
| 323 | #if defined(GL_EXT_texture_lod_bias) |
| 324 | { 1, GL_MAX_TEXTURE_LOD_BIAS_EXT, "GL_MAX_TEXTURE_LOD_BIAS_EXT" }, |
| 325 | #endif |
| 326 | #if defined(GL_EXT_texture_filter_anisotropic) |
| 327 | { 1, GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT" }, |
| 328 | #endif |
| 329 | #if defined(GL_ARB_draw_buffers) |
| 330 | { 1, GL_MAX_DRAW_BUFFERS_ARB, "GL_MAX_DRAW_BUFFERS_ARB" }, |
| 331 | #endif |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 332 | { 0, (GLenum) 0, NULL } |
| 333 | }; |
| 334 | GLint i, max[2]; |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 335 | |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 336 | printf("OpenGL limits:\n"); |
| 337 | for (i = 0; limits[i].count; i++) { |
| 338 | glGetIntegerv(limits[i].token, max); |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 339 | if (glGetError() == GL_NO_ERROR) { |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 340 | if (limits[i].count == 1) |
| 341 | printf(" %s = %d\n", limits[i].name, max[0]); |
| 342 | else /* XXX fix if we ever query something with more than 2 values */ |
| 343 | printf(" %s = %d, %d\n", limits[i].name, max[0], max[1]); |
| 344 | } |
| 345 | } |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 346 | |
Brian Paul | f2afdca | 2004-08-10 15:32:25 +0000 | [diff] [blame] | 347 | /* these don't fit into the above mechanism, unfortunately */ |
| 348 | glGetConvolutionParameteriv(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_WIDTH, max); |
| 349 | glGetConvolutionParameteriv(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_HEIGHT, max+1); |
| 350 | if (glGetError() == GL_NONE) { |
| 351 | printf(" GL_MAX_CONVOLUTION_WIDTH/HEIGHT = %d, %d\n", max[0], max[1]); |
| 352 | } |
| 353 | |
Brian Paul | 2ca741a | 2006-05-15 15:35:38 +0000 | [diff] [blame] | 354 | #if defined(GL_ARB_vertex_program) |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 355 | if (strstr(extensions, "GL_ARB_vertex_program")) { |
| 356 | print_program_limits(GL_VERTEX_PROGRAM_ARB); |
| 357 | } |
Brian Paul | 2ca741a | 2006-05-15 15:35:38 +0000 | [diff] [blame] | 358 | #endif |
| 359 | #if defined(GL_ARB_fragment_program) |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 360 | if (strstr(extensions, "GL_ARB_fragment_program")) { |
| 361 | print_program_limits(GL_FRAGMENT_PROGRAM_ARB); |
| 362 | } |
Brian Paul | 2ca741a | 2006-05-15 15:35:38 +0000 | [diff] [blame] | 363 | #endif |
| 364 | #if defined(GL_ARB_vertex_shader) |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 365 | if (strstr(extensions, "GL_ARB_vertex_shader")) { |
| 366 | print_shader_limits(GL_VERTEX_SHADER_ARB); |
| 367 | } |
Brian Paul | 2ca741a | 2006-05-15 15:35:38 +0000 | [diff] [blame] | 368 | #endif |
| 369 | #if defined(GL_ARB_fragment_shader) |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 370 | if (strstr(extensions, "GL_ARB_fragment_shader")) { |
| 371 | print_shader_limits(GL_FRAGMENT_SHADER_ARB); |
| 372 | } |
Brian Paul | 2ca741a | 2006-05-15 15:35:38 +0000 | [diff] [blame] | 373 | #endif |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | |
| 377 | static void |
| 378 | print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits) |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 379 | { |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 380 | Window win; |
Brian Paul | 8460cc9 | 2000-02-02 20:57:51 +0000 | [diff] [blame] | 381 | int attribSingle[] = { |
| 382 | GLX_RGBA, |
| 383 | GLX_RED_SIZE, 1, |
| 384 | GLX_GREEN_SIZE, 1, |
| 385 | GLX_BLUE_SIZE, 1, |
| 386 | None }; |
| 387 | int attribDouble[] = { |
| 388 | GLX_RGBA, |
| 389 | GLX_RED_SIZE, 1, |
| 390 | GLX_GREEN_SIZE, 1, |
| 391 | GLX_BLUE_SIZE, 1, |
| 392 | GLX_DOUBLEBUFFER, |
| 393 | None }; |
| 394 | |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 395 | XSetWindowAttributes attr; |
| 396 | unsigned long mask; |
| 397 | Window root; |
Kristian Høgsberg | a074857 | 2007-10-18 15:19:08 -0400 | [diff] [blame] | 398 | GLXContext ctx = NULL; |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 399 | XVisualInfo *visinfo; |
| 400 | int width = 100, height = 100; |
| 401 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 402 | root = RootWindow(dpy, scrnum); |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 403 | |
Brian Paul | ca7cd3a | 2009-12-04 08:09:55 -0700 | [diff] [blame^] | 404 | /* |
| 405 | * Find a basic GLX visual. We'll then create a rendering context and |
| 406 | * query various info strings. |
| 407 | */ |
Brian Paul | 8460cc9 | 2000-02-02 20:57:51 +0000 | [diff] [blame] | 408 | visinfo = glXChooseVisual(dpy, scrnum, attribSingle); |
Kristian Høgsberg | a074857 | 2007-10-18 15:19:08 -0400 | [diff] [blame] | 409 | if (!visinfo) |
Brian Paul | 8460cc9 | 2000-02-02 20:57:51 +0000 | [diff] [blame] | 410 | visinfo = glXChooseVisual(dpy, scrnum, attribDouble); |
Kristian Høgsberg | a074857 | 2007-10-18 15:19:08 -0400 | [diff] [blame] | 411 | |
| 412 | if (visinfo) |
| 413 | ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect ); |
| 414 | |
| 415 | #ifdef GLX_VERSION_1_3 |
Brian Paul | ca7cd3a | 2009-12-04 08:09:55 -0700 | [diff] [blame^] | 416 | /* Try glXChooseFBConfig() if glXChooseVisual didn't work. |
| 417 | * XXX when would that happen? |
| 418 | */ |
| 419 | if (!visinfo) { |
Kristian Høgsberg | a074857 | 2007-10-18 15:19:08 -0400 | [diff] [blame] | 420 | int fbAttribSingle[] = { |
| 421 | GLX_RENDER_TYPE, GLX_RGBA_BIT, |
| 422 | GLX_RED_SIZE, 1, |
| 423 | GLX_GREEN_SIZE, 1, |
| 424 | GLX_BLUE_SIZE, 1, |
Brian Paul | ca7cd3a | 2009-12-04 08:09:55 -0700 | [diff] [blame^] | 425 | GLX_DOUBLEBUFFER, GL_FALSE, |
Kristian Høgsberg | a074857 | 2007-10-18 15:19:08 -0400 | [diff] [blame] | 426 | None }; |
| 427 | int fbAttribDouble[] = { |
| 428 | GLX_RENDER_TYPE, GLX_RGBA_BIT, |
| 429 | GLX_RED_SIZE, 1, |
| 430 | GLX_GREEN_SIZE, 1, |
| 431 | GLX_BLUE_SIZE, 1, |
Brian Paul | ca7cd3a | 2009-12-04 08:09:55 -0700 | [diff] [blame^] | 432 | GLX_DOUBLEBUFFER, GL_TRUE, |
Kristian Høgsberg | a074857 | 2007-10-18 15:19:08 -0400 | [diff] [blame] | 433 | None }; |
| 434 | GLXFBConfig *configs = NULL; |
| 435 | int nConfigs; |
| 436 | |
Brian Paul | ca7cd3a | 2009-12-04 08:09:55 -0700 | [diff] [blame^] | 437 | configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs); |
| 438 | if (!configs) |
Kristian Høgsberg | a074857 | 2007-10-18 15:19:08 -0400 | [diff] [blame] | 439 | configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs); |
| 440 | |
| 441 | if (configs) { |
| 442 | visinfo = glXGetVisualFromFBConfig(dpy, configs[0]); |
| 443 | ctx = glXCreateNewContext(dpy, configs[0], GLX_RGBA_TYPE, NULL, allowDirect); |
| 444 | XFree(configs); |
Brian Paul | 8460cc9 | 2000-02-02 20:57:51 +0000 | [diff] [blame] | 445 | } |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 446 | } |
Kristian Høgsberg | a074857 | 2007-10-18 15:19:08 -0400 | [diff] [blame] | 447 | #endif |
| 448 | |
| 449 | if (!visinfo) { |
| 450 | fprintf(stderr, "Error: couldn't find RGB GLX visual or fbconfig\n"); |
| 451 | return; |
| 452 | } |
| 453 | |
| 454 | if (!ctx) { |
| 455 | fprintf(stderr, "Error: glXCreateContext failed\n"); |
| 456 | XFree(visinfo); |
Kristian Høgsberg | a074857 | 2007-10-18 15:19:08 -0400 | [diff] [blame] | 457 | return; |
| 458 | } |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 459 | |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 460 | attr.background_pixel = 0; |
| 461 | attr.border_pixel = 0; |
Brian Paul | 9cff558 | 2000-05-07 18:07:23 +0000 | [diff] [blame] | 462 | attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone); |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 463 | attr.event_mask = StructureNotifyMask | ExposureMask; |
| 464 | mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 465 | win = XCreateWindow(dpy, root, 0, 0, width, height, |
| 466 | 0, visinfo->depth, InputOutput, |
| 467 | visinfo->visual, mask, &attr); |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 468 | |
Brian Paul | 9cff558 | 2000-05-07 18:07:23 +0000 | [diff] [blame] | 469 | if (glXMakeCurrent(dpy, win, ctx)) { |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 470 | const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR); |
| 471 | const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION); |
| 472 | const char *serverExtensions = glXQueryServerString(dpy, scrnum, GLX_EXTENSIONS); |
Brian Paul | 34fb5db | 2000-04-22 20:31:23 +0000 | [diff] [blame] | 473 | const char *clientVendor = glXGetClientString(dpy, GLX_VENDOR); |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 474 | const char *clientVersion = glXGetClientString(dpy, GLX_VERSION); |
| 475 | const char *clientExtensions = glXGetClientString(dpy, GLX_EXTENSIONS); |
| 476 | const char *glxExtensions = glXQueryExtensionsString(dpy, scrnum); |
| 477 | const char *glVendor = (const char *) glGetString(GL_VENDOR); |
| 478 | const char *glRenderer = (const char *) glGetString(GL_RENDERER); |
| 479 | const char *glVersion = (const char *) glGetString(GL_VERSION); |
| 480 | const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS); |
Ian Romanick | c00fbd5 | 2004-02-23 17:37:36 +0000 | [diff] [blame] | 481 | int glxVersionMajor; |
| 482 | int glxVersionMinor; |
Brian Paul | 373aea1 | 2001-04-02 22:45:07 +0000 | [diff] [blame] | 483 | char *displayName = NULL; |
| 484 | char *colon = NULL, *period = NULL; |
Ian Romanick | c00fbd5 | 2004-02-23 17:37:36 +0000 | [diff] [blame] | 485 | |
| 486 | if (! glXQueryVersion( dpy, & glxVersionMajor, & glxVersionMinor )) { |
| 487 | fprintf(stderr, "Error: glXQueryVersion failed\n"); |
| 488 | exit(1); |
| 489 | } |
| 490 | |
Brian Paul | 373aea1 | 2001-04-02 22:45:07 +0000 | [diff] [blame] | 491 | /* Strip the screen number from the display name, if present. */ |
Brian Paul | f02a5f6 | 2002-07-12 15:54:01 +0000 | [diff] [blame] | 492 | if (!(displayName = (char *) malloc(strlen(DisplayString(dpy)) + 1))) { |
Brian Paul | 373aea1 | 2001-04-02 22:45:07 +0000 | [diff] [blame] | 493 | fprintf(stderr, "Error: malloc() failed\n"); |
| 494 | exit(1); |
| 495 | } |
| 496 | strcpy(displayName, DisplayString(dpy)); |
| 497 | colon = strrchr(displayName, ':'); |
| 498 | if (colon) { |
| 499 | period = strchr(colon, '.'); |
| 500 | if (period) |
| 501 | *period = '\0'; |
| 502 | } |
| 503 | printf("display: %s screen: %d\n", displayName, scrnum); |
| 504 | free(displayName); |
Michel Dänzer | b46e359 | 2006-12-06 14:54:43 +0100 | [diff] [blame] | 505 | printf("direct rendering: "); |
| 506 | if (glXIsDirect(dpy, ctx)) { |
| 507 | printf("Yes\n"); |
| 508 | } else { |
| 509 | if (!allowDirect) { |
| 510 | printf("No (-i specified)\n"); |
| 511 | } else if (getenv("LIBGL_ALWAYS_INDIRECT")) { |
| 512 | printf("No (LIBGL_ALWAYS_INDIRECT set)\n"); |
| 513 | } else { |
| 514 | printf("No (If you want to find out why, try setting " |
| 515 | "LIBGL_DEBUG=verbose)\n"); |
| 516 | } |
| 517 | } |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 518 | printf("server glx vendor string: %s\n", serverVendor); |
| 519 | printf("server glx version string: %s\n", serverVersion); |
| 520 | printf("server glx extensions:\n"); |
| 521 | print_extension_list(serverExtensions); |
Brian Paul | 34fb5db | 2000-04-22 20:31:23 +0000 | [diff] [blame] | 522 | printf("client glx vendor string: %s\n", clientVendor); |
| 523 | printf("client glx version string: %s\n", clientVersion); |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 524 | printf("client glx extensions:\n"); |
| 525 | print_extension_list(clientExtensions); |
Ian Romanick | c00fbd5 | 2004-02-23 17:37:36 +0000 | [diff] [blame] | 526 | printf("GLX version: %u.%u\n", glxVersionMajor, glxVersionMinor); |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 527 | printf("GLX extensions:\n"); |
| 528 | print_extension_list(glxExtensions); |
| 529 | printf("OpenGL vendor string: %s\n", glVendor); |
| 530 | printf("OpenGL renderer string: %s\n", glRenderer); |
| 531 | printf("OpenGL version string: %s\n", glVersion); |
Brian Paul | 51bfb6a | 2008-07-24 14:27:11 -0600 | [diff] [blame] | 532 | #ifdef GL_VERSION_2_0 |
| 533 | if (glVersion[0] >= '2' && glVersion[1] == '.') { |
| 534 | char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION); |
| 535 | printf("OpenGL shading language version string: %s\n", v); |
| 536 | } |
| 537 | #endif |
| 538 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 539 | printf("OpenGL extensions:\n"); |
| 540 | print_extension_list(glExtensions); |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 541 | if (limits) |
Brian Paul | ad7805d | 2006-05-13 00:18:12 +0000 | [diff] [blame] | 542 | print_limits(glExtensions); |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 543 | } |
Brian Paul | 9cff558 | 2000-05-07 18:07:23 +0000 | [diff] [blame] | 544 | else { |
| 545 | fprintf(stderr, "Error: glXMakeCurrent failed\n"); |
| 546 | } |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 547 | |
| 548 | glXDestroyContext(dpy, ctx); |
Brian Paul | 361bccb | 2006-01-16 16:17:18 +0000 | [diff] [blame] | 549 | XFree(visinfo); |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 550 | XDestroyWindow(dpy, win); |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | |
| 554 | static const char * |
| 555 | visual_class_name(int cls) |
| 556 | { |
| 557 | switch (cls) { |
| 558 | case StaticColor: |
| 559 | return "StaticColor"; |
| 560 | case PseudoColor: |
| 561 | return "PseudoColor"; |
| 562 | case StaticGray: |
| 563 | return "StaticGray"; |
| 564 | case GrayScale: |
| 565 | return "GrayScale"; |
| 566 | case TrueColor: |
| 567 | return "TrueColor"; |
| 568 | case DirectColor: |
| 569 | return "DirectColor"; |
| 570 | default: |
| 571 | return ""; |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | |
| 576 | static const char * |
| 577 | visual_class_abbrev(int cls) |
| 578 | { |
| 579 | switch (cls) { |
| 580 | case StaticColor: |
| 581 | return "sc"; |
| 582 | case PseudoColor: |
| 583 | return "pc"; |
| 584 | case StaticGray: |
| 585 | return "sg"; |
| 586 | case GrayScale: |
| 587 | return "gs"; |
| 588 | case TrueColor: |
| 589 | return "tc"; |
| 590 | case DirectColor: |
| 591 | return "dc"; |
| 592 | default: |
| 593 | return ""; |
| 594 | } |
| 595 | } |
| 596 | |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 597 | static const char * |
| 598 | visual_render_type_name(int type) |
| 599 | { |
| 600 | switch (type) { |
| 601 | case GLX_RGBA_BIT: |
| 602 | return "rgba"; |
| 603 | case GLX_COLOR_INDEX_BIT: |
| 604 | return "ci"; |
| 605 | case GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT: |
| 606 | return "rgba|ci"; |
| 607 | default: |
| 608 | return ""; |
| 609 | } |
| 610 | } |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 611 | |
Kristian Høgsberg | f7d1d55 | 2007-10-15 20:12:01 -0400 | [diff] [blame] | 612 | static GLboolean |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 613 | get_visual_attribs(Display *dpy, XVisualInfo *vInfo, |
| 614 | struct visual_attribs *attribs) |
| 615 | { |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 616 | const char *ext = glXQueryExtensionsString(dpy, vInfo->screen); |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 617 | int rgba; |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 618 | |
Brian Paul | a9c53fa | 2000-04-03 15:45:34 +0000 | [diff] [blame] | 619 | memset(attribs, 0, sizeof(struct visual_attribs)); |
| 620 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 621 | attribs->id = vInfo->visualid; |
| 622 | #if defined(__cplusplus) || defined(c_plusplus) |
| 623 | attribs->klass = vInfo->c_class; |
| 624 | #else |
| 625 | attribs->klass = vInfo->class; |
| 626 | #endif |
| 627 | attribs->depth = vInfo->depth; |
| 628 | attribs->redMask = vInfo->red_mask; |
| 629 | attribs->greenMask = vInfo->green_mask; |
| 630 | attribs->blueMask = vInfo->blue_mask; |
| 631 | attribs->colormapSize = vInfo->colormap_size; |
| 632 | attribs->bitsPerRGB = vInfo->bits_per_rgb; |
| 633 | |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 634 | if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0 || |
| 635 | !attribs->supportsGL) |
Kristian Høgsberg | f7d1d55 | 2007-10-15 20:12:01 -0400 | [diff] [blame] | 636 | return GL_FALSE; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 637 | glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize); |
| 638 | glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level); |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 639 | glXGetConfig(dpy, vInfo, GLX_RGBA, &rgba); |
| 640 | if (rgba) |
| 641 | attribs->render_type = GLX_RGBA_BIT; |
| 642 | else |
| 643 | attribs->render_type = GLX_COLOR_INDEX_BIT; |
| 644 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 645 | glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer); |
| 646 | glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo); |
| 647 | glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers); |
| 648 | glXGetConfig(dpy, vInfo, GLX_RED_SIZE, &attribs->redSize); |
| 649 | glXGetConfig(dpy, vInfo, GLX_GREEN_SIZE, &attribs->greenSize); |
| 650 | glXGetConfig(dpy, vInfo, GLX_BLUE_SIZE, &attribs->blueSize); |
| 651 | glXGetConfig(dpy, vInfo, GLX_ALPHA_SIZE, &attribs->alphaSize); |
| 652 | glXGetConfig(dpy, vInfo, GLX_DEPTH_SIZE, &attribs->depthSize); |
| 653 | glXGetConfig(dpy, vInfo, GLX_STENCIL_SIZE, &attribs->stencilSize); |
| 654 | glXGetConfig(dpy, vInfo, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize); |
| 655 | glXGetConfig(dpy, vInfo, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize); |
| 656 | glXGetConfig(dpy, vInfo, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize); |
| 657 | glXGetConfig(dpy, vInfo, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize); |
| 658 | |
Brian Paul | 45c5698 | 2002-10-14 13:57:23 +0000 | [diff] [blame] | 659 | /* get transparent pixel stuff */ |
| 660 | glXGetConfig(dpy, vInfo,GLX_TRANSPARENT_TYPE, &attribs->transparentType); |
| 661 | if (attribs->transparentType == GLX_TRANSPARENT_RGB) { |
| 662 | glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue); |
| 663 | glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue); |
| 664 | glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue); |
| 665 | glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue); |
| 666 | } |
| 667 | else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { |
| 668 | glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue); |
| 669 | } |
Brian Paul | e06c7f3 | 2000-01-27 16:53:55 +0000 | [diff] [blame] | 670 | |
Brian Paul | d2e39bb | 2002-11-04 16:24:18 +0000 | [diff] [blame] | 671 | /* multisample attribs */ |
| 672 | #ifdef GLX_ARB_multisample |
Adam Jackson | e1ae5b8 | 2008-01-22 14:57:20 -0500 | [diff] [blame] | 673 | if (ext && strstr(ext, "GLX_ARB_multisample")) { |
Brian Paul | d2e39bb | 2002-11-04 16:24:18 +0000 | [diff] [blame] | 674 | glXGetConfig(dpy, vInfo, GLX_SAMPLE_BUFFERS_ARB, &attribs->numMultisample); |
| 675 | glXGetConfig(dpy, vInfo, GLX_SAMPLES_ARB, &attribs->numSamples); |
| 676 | } |
| 677 | #endif |
| 678 | else { |
| 679 | attribs->numSamples = 0; |
| 680 | attribs->numMultisample = 0; |
| 681 | } |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 682 | |
| 683 | #if defined(GLX_EXT_visual_rating) |
| 684 | if (ext && strstr(ext, "GLX_EXT_visual_rating")) { |
| 685 | glXGetConfig(dpy, vInfo, GLX_VISUAL_CAVEAT_EXT, &attribs->visualCaveat); |
| 686 | } |
| 687 | else { |
| 688 | attribs->visualCaveat = GLX_NONE_EXT; |
| 689 | } |
| 690 | #else |
| 691 | attribs->visualCaveat = 0; |
| 692 | #endif |
Kristian Høgsberg | f7d1d55 | 2007-10-15 20:12:01 -0400 | [diff] [blame] | 693 | |
| 694 | return GL_TRUE; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 695 | } |
| 696 | |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 697 | #ifdef GLX_VERSION_1_3 |
| 698 | |
| 699 | static int |
| 700 | glx_token_to_visual_class(int visual_type) |
| 701 | { |
| 702 | switch (visual_type) { |
| 703 | case GLX_TRUE_COLOR: |
| 704 | return TrueColor; |
| 705 | case GLX_DIRECT_COLOR: |
| 706 | return DirectColor; |
| 707 | case GLX_PSEUDO_COLOR: |
| 708 | return PseudoColor; |
| 709 | case GLX_STATIC_COLOR: |
| 710 | return StaticColor; |
| 711 | case GLX_GRAY_SCALE: |
| 712 | return GrayScale; |
| 713 | case GLX_STATIC_GRAY: |
| 714 | return StaticGray; |
| 715 | case GLX_NONE: |
| 716 | default: |
| 717 | return None; |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | static GLboolean |
| 722 | get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig, |
| 723 | struct visual_attribs *attribs) |
| 724 | { |
| 725 | int visual_type; |
| 726 | |
| 727 | memset(attribs, 0, sizeof(struct visual_attribs)); |
| 728 | |
| 729 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &attribs->id); |
| 730 | |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 731 | #if 0 |
| 732 | attribs->depth = vInfo->depth; |
| 733 | attribs->redMask = vInfo->red_mask; |
| 734 | attribs->greenMask = vInfo->green_mask; |
| 735 | attribs->blueMask = vInfo->blue_mask; |
| 736 | attribs->colormapSize = vInfo->colormap_size; |
| 737 | attribs->bitsPerRGB = vInfo->bits_per_rgb; |
| 738 | #endif |
| 739 | |
| 740 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type); |
| 741 | attribs->klass = glx_token_to_visual_class(visual_type); |
| 742 | |
| 743 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_BUFFER_SIZE, &attribs->bufferSize); |
| 744 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level); |
| 745 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type); |
| 746 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &attribs->doubleBuffer); |
| 747 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_STEREO, &attribs->stereo); |
| 748 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_AUX_BUFFERS, &attribs->auxBuffers); |
| 749 | |
| 750 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_RED_SIZE, &attribs->redSize); |
| 751 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_GREEN_SIZE, &attribs->greenSize); |
| 752 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_BLUE_SIZE, &attribs->blueSize); |
| 753 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_ALPHA_SIZE, &attribs->alphaSize); |
| 754 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_DEPTH_SIZE, &attribs->depthSize); |
| 755 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_STENCIL_SIZE, &attribs->stencilSize); |
| 756 | |
| 757 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize); |
| 758 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize); |
| 759 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize); |
| 760 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize); |
| 761 | |
| 762 | /* get transparent pixel stuff */ |
| 763 | glXGetFBConfigAttrib(dpy, fbconfig,GLX_TRANSPARENT_TYPE, &attribs->transparentType); |
| 764 | if (attribs->transparentType == GLX_TRANSPARENT_RGB) { |
| 765 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue); |
| 766 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue); |
| 767 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue); |
| 768 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue); |
| 769 | } |
| 770 | else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { |
| 771 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue); |
| 772 | } |
| 773 | |
| 774 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLE_BUFFERS, &attribs->numMultisample); |
| 775 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLES, &attribs->numSamples); |
| 776 | glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat); |
| 777 | |
| 778 | return GL_TRUE; |
| 779 | } |
| 780 | |
| 781 | #endif |
| 782 | |
| 783 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 784 | |
| 785 | static void |
| 786 | print_visual_attribs_verbose(const struct visual_attribs *attribs) |
| 787 | { |
| 788 | printf("Visual ID: %x depth=%d class=%s\n", |
| 789 | attribs->id, attribs->depth, visual_class_name(attribs->klass)); |
| 790 | printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n", |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 791 | attribs->bufferSize, attribs->level, |
| 792 | visual_render_type_name(attribs->render_type), |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 793 | attribs->doubleBuffer, attribs->stereo); |
| 794 | printf(" rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n", |
| 795 | attribs->redSize, attribs->greenSize, |
| 796 | attribs->blueSize, attribs->alphaSize); |
| 797 | printf(" auxBuffers=%d depthSize=%d stencilSize=%d\n", |
| 798 | attribs->auxBuffers, attribs->depthSize, attribs->stencilSize); |
| 799 | printf(" accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n", |
| 800 | attribs->accumRedSize, attribs->accumGreenSize, |
| 801 | attribs->accumBlueSize, attribs->accumAlphaSize); |
| 802 | printf(" multiSample=%d multiSampleBuffers=%d\n", |
| 803 | attribs->numSamples, attribs->numMultisample); |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 804 | #ifdef GLX_EXT_visual_rating |
| 805 | if (attribs->visualCaveat == GLX_NONE_EXT || attribs->visualCaveat == 0) |
Brian Paul | a9c53fa | 2000-04-03 15:45:34 +0000 | [diff] [blame] | 806 | printf(" visualCaveat=None\n"); |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 807 | else if (attribs->visualCaveat == GLX_SLOW_VISUAL_EXT) |
Brian Paul | a9c53fa | 2000-04-03 15:45:34 +0000 | [diff] [blame] | 808 | printf(" visualCaveat=Slow\n"); |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 809 | else if (attribs->visualCaveat == GLX_NON_CONFORMANT_VISUAL_EXT) |
Brian Paul | a9c53fa | 2000-04-03 15:45:34 +0000 | [diff] [blame] | 810 | printf(" visualCaveat=Nonconformant\n"); |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 811 | #endif |
Brian Paul | 45c5698 | 2002-10-14 13:57:23 +0000 | [diff] [blame] | 812 | if (attribs->transparentType == GLX_NONE) { |
| 813 | printf(" Opaque.\n"); |
| 814 | } |
| 815 | else if (attribs->transparentType == GLX_TRANSPARENT_RGB) { |
| 816 | printf(" Transparent RGB: Red=%d Green=%d Blue=%d Alpha=%d\n",attribs->transparentRedValue,attribs->transparentGreenValue,attribs->transparentBlueValue,attribs->transparentAlphaValue); |
| 817 | } |
| 818 | else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { |
| 819 | printf(" Transparent index=%d\n",attribs->transparentIndexValue); |
| 820 | } |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | |
| 824 | static void |
| 825 | print_visual_attribs_short_header(void) |
| 826 | { |
Brian Paul | a9c53fa | 2000-04-03 15:45:34 +0000 | [diff] [blame] | 827 | printf(" visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav\n"); |
| 828 | printf(" id dep cl sp sz l ci b ro r g b a bf th cl r g b a ns b eat\n"); |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 829 | printf("----------------------------------------------------------------------\n"); |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | |
| 833 | static void |
| 834 | print_visual_attribs_short(const struct visual_attribs *attribs) |
| 835 | { |
Brian Paul | a3e44f4 | 2002-03-08 19:44:28 +0000 | [diff] [blame] | 836 | char *caveat = NULL; |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 837 | #ifdef GLX_EXT_visual_rating |
| 838 | if (attribs->visualCaveat == GLX_NONE_EXT || attribs->visualCaveat == 0) |
| 839 | caveat = "None"; |
| 840 | else if (attribs->visualCaveat == GLX_SLOW_VISUAL_EXT) |
| 841 | caveat = "Slow"; |
| 842 | else if (attribs->visualCaveat == GLX_NON_CONFORMANT_VISUAL_EXT) |
| 843 | caveat = "Ncon"; |
Brian Paul | 28bc6cb | 2002-09-06 03:47:34 +0000 | [diff] [blame] | 844 | else |
| 845 | caveat = "None"; |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 846 | #else |
| 847 | caveat = "None"; |
| 848 | #endif |
| 849 | |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 850 | printf("0x%02x %2d %2s %2d %2d %2d %c%c %c %c %2d %2d %2d %2d %2d %2d %2d", |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 851 | attribs->id, |
| 852 | attribs->depth, |
| 853 | visual_class_abbrev(attribs->klass), |
Brian Paul | 45c5698 | 2002-10-14 13:57:23 +0000 | [diff] [blame] | 854 | attribs->transparentType != GLX_NONE, |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 855 | attribs->bufferSize, |
| 856 | attribs->level, |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 857 | (attribs->render_type & GLX_RGBA_BIT) ? 'r' : ' ', |
| 858 | (attribs->render_type & GLX_COLOR_INDEX_BIT) ? 'c' : ' ', |
| 859 | attribs->doubleBuffer ? 'y' : '.', |
| 860 | attribs->stereo ? 'y' : '.', |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 861 | attribs->redSize, attribs->greenSize, |
| 862 | attribs->blueSize, attribs->alphaSize, |
| 863 | attribs->auxBuffers, |
| 864 | attribs->depthSize, |
| 865 | attribs->stencilSize |
| 866 | ); |
| 867 | |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 868 | printf(" %2d %2d %2d %2d %2d %1d %s\n", |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 869 | attribs->accumRedSize, attribs->accumGreenSize, |
| 870 | attribs->accumBlueSize, attribs->accumAlphaSize, |
Brian Paul | 25673f0 | 2000-03-31 18:17:51 +0000 | [diff] [blame] | 871 | attribs->numSamples, attribs->numMultisample, |
| 872 | caveat |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 873 | ); |
| 874 | } |
| 875 | |
| 876 | |
| 877 | static void |
| 878 | print_visual_attribs_long_header(void) |
| 879 | { |
| 880 | printf("Vis Vis Visual Trans buff lev render DB ste r g b a aux dep ste accum buffers MS MS\n"); |
| 881 | printf(" ID Depth Type parent size el type reo sz sz sz sz buf th ncl r g b a num bufs\n"); |
| 882 | printf("----------------------------------------------------------------------------------------------------\n"); |
| 883 | } |
| 884 | |
| 885 | |
| 886 | static void |
| 887 | print_visual_attribs_long(const struct visual_attribs *attribs) |
| 888 | { |
| 889 | printf("0x%2x %2d %-11s %2d %2d %2d %4s %3d %3d %3d %3d %3d %3d", |
| 890 | attribs->id, |
| 891 | attribs->depth, |
| 892 | visual_class_name(attribs->klass), |
Brian Paul | 45c5698 | 2002-10-14 13:57:23 +0000 | [diff] [blame] | 893 | attribs->transparentType != GLX_NONE, |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 894 | attribs->bufferSize, |
| 895 | attribs->level, |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 896 | visual_render_type_name(attribs->render_type), |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 897 | attribs->doubleBuffer, |
| 898 | attribs->stereo, |
| 899 | attribs->redSize, attribs->greenSize, |
| 900 | attribs->blueSize, attribs->alphaSize |
| 901 | ); |
| 902 | |
| 903 | printf(" %3d %4d %2d %3d %3d %3d %3d %2d %2d\n", |
| 904 | attribs->auxBuffers, |
| 905 | attribs->depthSize, |
| 906 | attribs->stencilSize, |
| 907 | attribs->accumRedSize, attribs->accumGreenSize, |
| 908 | attribs->accumBlueSize, attribs->accumAlphaSize, |
| 909 | attribs->numSamples, attribs->numMultisample |
| 910 | ); |
| 911 | } |
| 912 | |
| 913 | |
| 914 | static void |
| 915 | print_visual_info(Display *dpy, int scrnum, InfoMode mode) |
| 916 | { |
Brian Paul | f02a5f6 | 2002-07-12 15:54:01 +0000 | [diff] [blame] | 917 | XVisualInfo theTemplate; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 918 | XVisualInfo *visuals; |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 919 | int numVisuals, numGlxVisuals; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 920 | long mask; |
| 921 | int i; |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 922 | struct visual_attribs attribs; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 923 | |
| 924 | /* get list of all visuals on this screen */ |
Brian Paul | f02a5f6 | 2002-07-12 15:54:01 +0000 | [diff] [blame] | 925 | theTemplate.screen = scrnum; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 926 | mask = VisualScreenMask; |
Brian Paul | f02a5f6 | 2002-07-12 15:54:01 +0000 | [diff] [blame] | 927 | visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals); |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 928 | |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 929 | numGlxVisuals = 0; |
| 930 | for (i = 0; i < numVisuals; i++) { |
| 931 | if (get_visual_attribs(dpy, &visuals[i], &attribs)) |
| 932 | numGlxVisuals++; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 933 | } |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 934 | |
| 935 | if (numGlxVisuals == 0) |
| 936 | return; |
| 937 | |
| 938 | printf("%d GLX Visuals\n", numGlxVisuals); |
| 939 | |
| 940 | if (mode == Normal) |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 941 | print_visual_attribs_short_header(); |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 942 | else if (mode == Wide) |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 943 | print_visual_attribs_long_header(); |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 944 | |
| 945 | for (i = 0; i < numVisuals; i++) { |
| 946 | if (!get_visual_attribs(dpy, &visuals[i], &attribs)) |
| 947 | continue; |
| 948 | |
| 949 | if (mode == Verbose) |
| 950 | print_visual_attribs_verbose(&attribs); |
| 951 | else if (mode == Normal) |
| 952 | print_visual_attribs_short(&attribs); |
| 953 | else if (mode == Wide) |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 954 | print_visual_attribs_long(&attribs); |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 955 | } |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 956 | printf("\n"); |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 957 | |
| 958 | XFree(visuals); |
| 959 | } |
| 960 | |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 961 | #ifdef GLX_VERSION_1_3 |
| 962 | |
| 963 | static void |
| 964 | print_fbconfig_info(Display *dpy, int scrnum, InfoMode mode) |
| 965 | { |
| 966 | int numFBConfigs; |
| 967 | struct visual_attribs attribs; |
| 968 | GLXFBConfig *fbconfigs; |
| 969 | int i; |
| 970 | |
| 971 | /* get list of all fbconfigs on this screen */ |
| 972 | fbconfigs = glXGetFBConfigs(dpy, scrnum, &numFBConfigs); |
| 973 | |
Vinson Lee | 7324c22 | 2009-11-20 13:01:22 -0800 | [diff] [blame] | 974 | if (numFBConfigs == 0) { |
| 975 | XFree(fbconfigs); |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 976 | return; |
Vinson Lee | 7324c22 | 2009-11-20 13:01:22 -0800 | [diff] [blame] | 977 | } |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 978 | |
Kristian Høgsberg | a5b4bb3 | 2007-10-17 14:43:35 -0400 | [diff] [blame] | 979 | printf("%d GLXFBConfigs:\n", numFBConfigs); |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 980 | if (mode == Normal) |
| 981 | print_visual_attribs_short_header(); |
| 982 | else if (mode == Wide) |
| 983 | print_visual_attribs_long_header(); |
| 984 | |
| 985 | for (i = 0; i < numFBConfigs; i++) { |
| 986 | get_fbconfig_attribs(dpy, fbconfigs[i], &attribs); |
| 987 | |
| 988 | if (mode == Verbose) |
| 989 | print_visual_attribs_verbose(&attribs); |
| 990 | else if (mode == Normal) |
| 991 | print_visual_attribs_short(&attribs); |
| 992 | else if (mode == Wide) |
| 993 | print_visual_attribs_long(&attribs); |
| 994 | } |
| 995 | printf("\n"); |
| 996 | |
| 997 | XFree(fbconfigs); |
| 998 | } |
| 999 | |
| 1000 | #endif |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 1001 | |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1002 | /* |
| 1003 | * Stand-alone Mesa doesn't really implement the GLX protocol so it |
| 1004 | * doesn't really know the GLX attributes associated with an X visual. |
| 1005 | * The first time a visual is presented to Mesa's pseudo-GLX it |
| 1006 | * attaches ancilliary buffers to it (like depth and stencil). |
| 1007 | * But that usually only works if glXChooseVisual is used. |
| 1008 | * This function calls glXChooseVisual() to sort of "prime the pump" |
| 1009 | * for Mesa's GLX so that the visuals that get reported actually |
| 1010 | * reflect what applications will see. |
| 1011 | * This has no effect when using true GLX. |
| 1012 | */ |
| 1013 | static void |
| 1014 | mesa_hack(Display *dpy, int scrnum) |
| 1015 | { |
| 1016 | static int attribs[] = { |
| 1017 | GLX_RGBA, |
| 1018 | GLX_RED_SIZE, 1, |
| 1019 | GLX_GREEN_SIZE, 1, |
| 1020 | GLX_BLUE_SIZE, 1, |
| 1021 | GLX_DEPTH_SIZE, 1, |
| 1022 | GLX_STENCIL_SIZE, 1, |
| 1023 | GLX_ACCUM_RED_SIZE, 1, |
| 1024 | GLX_ACCUM_GREEN_SIZE, 1, |
| 1025 | GLX_ACCUM_BLUE_SIZE, 1, |
| 1026 | GLX_ACCUM_ALPHA_SIZE, 1, |
| 1027 | GLX_DOUBLEBUFFER, |
| 1028 | None |
| 1029 | }; |
| 1030 | XVisualInfo *visinfo; |
| 1031 | |
| 1032 | visinfo = glXChooseVisual(dpy, scrnum, attribs); |
| 1033 | if (visinfo) |
| 1034 | XFree(visinfo); |
| 1035 | } |
| 1036 | |
| 1037 | |
| 1038 | /* |
| 1039 | * Examine all visuals to find the so-called best one. |
| 1040 | * We prefer deepest RGBA buffer with depth, stencil and accum |
| 1041 | * that has no caveats. |
| 1042 | */ |
| 1043 | static int |
| 1044 | find_best_visual(Display *dpy, int scrnum) |
| 1045 | { |
Brian Paul | f02a5f6 | 2002-07-12 15:54:01 +0000 | [diff] [blame] | 1046 | XVisualInfo theTemplate; |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1047 | XVisualInfo *visuals; |
| 1048 | int numVisuals; |
| 1049 | long mask; |
| 1050 | int i; |
| 1051 | struct visual_attribs bestVis; |
| 1052 | |
| 1053 | /* get list of all visuals on this screen */ |
Brian Paul | f02a5f6 | 2002-07-12 15:54:01 +0000 | [diff] [blame] | 1054 | theTemplate.screen = scrnum; |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1055 | mask = VisualScreenMask; |
Brian Paul | f02a5f6 | 2002-07-12 15:54:01 +0000 | [diff] [blame] | 1056 | visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals); |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1057 | |
| 1058 | /* init bestVis with first visual info */ |
| 1059 | get_visual_attribs(dpy, &visuals[0], &bestVis); |
| 1060 | |
| 1061 | /* try to find a "better" visual */ |
| 1062 | for (i = 1; i < numVisuals; i++) { |
| 1063 | struct visual_attribs vis; |
| 1064 | |
| 1065 | get_visual_attribs(dpy, &visuals[i], &vis); |
| 1066 | |
| 1067 | /* always skip visuals with caveats */ |
| 1068 | if (vis.visualCaveat != GLX_NONE_EXT) |
| 1069 | continue; |
| 1070 | |
| 1071 | /* see if this vis is better than bestVis */ |
| 1072 | if ((!bestVis.supportsGL && vis.supportsGL) || |
| 1073 | (bestVis.visualCaveat != GLX_NONE_EXT) || |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 1074 | (!(bestVis.render_type & GLX_RGBA_BIT) && (vis.render_type & GLX_RGBA_BIT)) || |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1075 | (!bestVis.doubleBuffer && vis.doubleBuffer) || |
| 1076 | (bestVis.redSize < vis.redSize) || |
| 1077 | (bestVis.greenSize < vis.greenSize) || |
| 1078 | (bestVis.blueSize < vis.blueSize) || |
| 1079 | (bestVis.alphaSize < vis.alphaSize) || |
| 1080 | (bestVis.depthSize < vis.depthSize) || |
| 1081 | (bestVis.stencilSize < vis.stencilSize) || |
| 1082 | (bestVis.accumRedSize < vis.accumRedSize)) { |
| 1083 | /* found a better visual */ |
| 1084 | bestVis = vis; |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | XFree(visuals); |
| 1089 | |
| 1090 | return bestVis.id; |
| 1091 | } |
| 1092 | |
| 1093 | |
Brian Paul | 08b3ff1 | 2001-04-24 20:57:36 +0000 | [diff] [blame] | 1094 | static void |
| 1095 | usage(void) |
| 1096 | { |
| 1097 | printf("Usage: glxinfo [-v] [-t] [-h] [-i] [-b] [-display <dname>]\n"); |
| 1098 | printf("\t-v: Print visuals info in verbose form.\n"); |
| 1099 | printf("\t-t: Print verbose table.\n"); |
| 1100 | printf("\t-display <dname>: Print GLX visuals on specified server.\n"); |
| 1101 | printf("\t-h: This information.\n"); |
| 1102 | printf("\t-i: Force an indirect rendering context.\n"); |
| 1103 | printf("\t-b: Find the 'best' visual and print it's number.\n"); |
Brian Paul | 0b77a1c | 2003-04-09 21:50:08 +0000 | [diff] [blame] | 1104 | printf("\t-l: Print interesting OpenGL limits.\n"); |
Brian Paul | 08b3ff1 | 2001-04-24 20:57:36 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
| 1107 | |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 1108 | int |
| 1109 | main(int argc, char *argv[]) |
| 1110 | { |
Alan Hourihane | e18599a | 2001-03-19 13:58:45 +0000 | [diff] [blame] | 1111 | char *displayName = NULL; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 1112 | Display *dpy; |
| 1113 | int numScreens, scrnum; |
| 1114 | InfoMode mode = Normal; |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1115 | GLboolean findBest = GL_FALSE; |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 1116 | GLboolean limits = GL_FALSE; |
Brian Paul | 08b3ff1 | 2001-04-24 20:57:36 +0000 | [diff] [blame] | 1117 | Bool allowDirect = True; |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 1118 | int i; |
| 1119 | |
| 1120 | for (i = 1; i < argc; i++) { |
| 1121 | if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) { |
| 1122 | displayName = argv[i + 1]; |
| 1123 | i++; |
| 1124 | } |
| 1125 | else if (strcmp(argv[i], "-t") == 0) { |
| 1126 | mode = Wide; |
| 1127 | } |
| 1128 | else if (strcmp(argv[i], "-v") == 0) { |
| 1129 | mode = Verbose; |
| 1130 | } |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1131 | else if (strcmp(argv[i], "-b") == 0) { |
| 1132 | findBest = GL_TRUE; |
| 1133 | } |
Brian Paul | 08b3ff1 | 2001-04-24 20:57:36 +0000 | [diff] [blame] | 1134 | else if (strcmp(argv[i], "-i") == 0) { |
| 1135 | allowDirect = False; |
| 1136 | } |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 1137 | else if (strcmp(argv[i], "-l") == 0) { |
| 1138 | limits = GL_TRUE; |
| 1139 | } |
Brian Paul | 08b3ff1 | 2001-04-24 20:57:36 +0000 | [diff] [blame] | 1140 | else if (strcmp(argv[i], "-h") == 0) { |
| 1141 | usage(); |
| 1142 | return 0; |
| 1143 | } |
| 1144 | else { |
| 1145 | printf("Unknown option `%s'\n", argv[i]); |
| 1146 | usage(); |
| 1147 | return 0; |
| 1148 | } |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
| 1151 | dpy = XOpenDisplay(displayName); |
| 1152 | if (!dpy) { |
Brian | 73eee24 | 2006-12-13 08:30:26 -0700 | [diff] [blame] | 1153 | fprintf(stderr, "Error: unable to open display %s\n", XDisplayName(displayName)); |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 1154 | return -1; |
| 1155 | } |
| 1156 | |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1157 | if (findBest) { |
| 1158 | int b; |
| 1159 | mesa_hack(dpy, 0); |
| 1160 | b = find_best_visual(dpy, 0); |
| 1161 | printf("%d\n", b); |
| 1162 | } |
| 1163 | else { |
| 1164 | numScreens = ScreenCount(dpy); |
Brian Paul | 373aea1 | 2001-04-02 22:45:07 +0000 | [diff] [blame] | 1165 | print_display_info(dpy); |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1166 | for (scrnum = 0; scrnum < numScreens; scrnum++) { |
| 1167 | mesa_hack(dpy, scrnum); |
Brian Paul | 2f7ef5f | 2002-09-06 03:35:43 +0000 | [diff] [blame] | 1168 | print_screen_info(dpy, scrnum, allowDirect, limits); |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1169 | printf("\n"); |
| 1170 | print_visual_info(dpy, scrnum, mode); |
Kristian Høgsberg | 87966ba | 2007-10-17 10:14:55 -0400 | [diff] [blame] | 1171 | #ifdef GLX_VERSION_1_3 |
Kristian Høgsberg | 791ad0e | 2007-10-16 16:01:34 -0400 | [diff] [blame] | 1172 | print_fbconfig_info(dpy, scrnum, mode); |
Kristian Høgsberg | 87966ba | 2007-10-17 10:14:55 -0400 | [diff] [blame] | 1173 | #endif |
Brian Paul | 39557c3 | 2001-03-23 21:41:44 +0000 | [diff] [blame] | 1174 | if (scrnum + 1 < numScreens) |
| 1175 | printf("\n\n"); |
| 1176 | } |
Brian Paul | 76bc440 | 2000-01-27 16:43:56 +0000 | [diff] [blame] | 1177 | } |
| 1178 | |
Brian Paul | d2bfe1e | 1999-09-16 16:40:46 +0000 | [diff] [blame] | 1179 | XCloseDisplay(dpy); |
| 1180 | |
| 1181 | return 0; |
| 1182 | } |