[Mesa-dev] [PATCH 2/2] wglinfo: use common code from glinfo_common.c

Brian Paul brianp at vmware.com
Thu May 22 19:53:39 PDT 2014


---
 src/wgl/CMakeLists.txt |    3 +-
 src/wgl/wglinfo.c      |  532 ++----------------------------------------------
 2 files changed, 18 insertions(+), 517 deletions(-)

diff --git a/src/wgl/CMakeLists.txt b/src/wgl/CMakeLists.txt
index a32a664..d45cbf3 100644
--- a/src/wgl/CMakeLists.txt
+++ b/src/wgl/CMakeLists.txt
@@ -1,6 +1,7 @@
 include_directories (
 	${OPENGL_INCLUDE_PATH}
 	${GLEW_INCLUDE_DIR}
+	../xdemos
 )
 
 link_libraries (
@@ -12,7 +13,7 @@ add_executable (wglthreads wglthreads.c)
 add_executable (wgl_sharedtex_mt sharedtex_mt.c)
 set_target_properties (wgl_sharedtex_mt PROPERTIES OUTPUT_NAME sharedtex_mt)
 
-add_executable (wglinfo wglinfo.c)
+add_executable (wglinfo wglinfo.c ../xdemos/glinfo_common.c)
 add_executable (wglcontext wglcontext.c)
 add_executable (wincopy WIN32 wincopy.c wglutil.c)
 
diff --git a/src/wgl/wglinfo.c b/src/wgl/wglinfo.c
index b54c3b6..2b2c921 100644
--- a/src/wgl/wglinfo.c
+++ b/src/wgl/wglinfo.c
@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include "glinfo_common.h"
 
 
 typedef enum
@@ -49,520 +50,6 @@ typedef enum
 } InfoMode;
 
 
-/**
- * Return the GL enum name for a numeric value.
- * We really only care about the compressed texture formats for now.
- */
-static const char *
-enum_name(GLenum val)
-{
-   static const struct {
-      const char *name;
-      GLenum val;
-   } enums [] = {
-      { "GL_COMPRESSED_ALPHA", 0x84E9 },
-      { "GL_COMPRESSED_LUMINANCE", 0x84EA },
-      { "GL_COMPRESSED_LUMINANCE_ALPHA", 0x84EB },
-      { "GL_COMPRESSED_INTENSITY", 0x84EC },
-      { "GL_COMPRESSED_RGB", 0x84ED },
-      { "GL_COMPRESSED_RGBA", 0x84EE },
-      { "GL_COMPRESSED_TEXTURE_FORMATS", 0x86A3 },
-      { "GL_COMPRESSED_RGB", 0x84ED },
-      { "GL_COMPRESSED_RGBA", 0x84EE },
-      { "GL_COMPRESSED_TEXTURE_FORMATS", 0x86A3 },
-      { "GL_COMPRESSED_ALPHA", 0x84E9 },
-      { "GL_COMPRESSED_LUMINANCE", 0x84EA },
-      { "GL_COMPRESSED_LUMINANCE_ALPHA", 0x84EB },
-      { "GL_COMPRESSED_INTENSITY", 0x84EC },
-      { "GL_COMPRESSED_SRGB", 0x8C48 },
-      { "GL_COMPRESSED_SRGB_ALPHA", 0x8C49 },
-      { "GL_COMPRESSED_SLUMINANCE", 0x8C4A },
-      { "GL_COMPRESSED_SLUMINANCE_ALPHA", 0x8C4B },
-      { "GL_COMPRESSED_RED", 0x8225 },
-      { "GL_COMPRESSED_RG", 0x8226 },
-      { "GL_COMPRESSED_RED_RGTC1", 0x8DBB },
-      { "GL_COMPRESSED_SIGNED_RED_RGTC1", 0x8DBC },
-      { "GL_COMPRESSED_RG_RGTC2", 0x8DBD },
-      { "GL_COMPRESSED_SIGNED_RG_RGTC2", 0x8DBE },
-      { "GL_COMPRESSED_RGB8_ETC2", 0x9274 },
-      { "GL_COMPRESSED_SRGB8_ETC2", 0x9275 },
-      { "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", 0x9276 },
-      { "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", 0x9277 },
-      { "GL_COMPRESSED_RGBA8_ETC2_EAC", 0x9278 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", 0x9279 },
-      { "GL_COMPRESSED_R11_EAC", 0x9270 },
-      { "GL_COMPRESSED_SIGNED_R11_EAC", 0x9271 },
-      { "GL_COMPRESSED_RG11_EAC", 0x9272 },
-      { "GL_COMPRESSED_SIGNED_RG11_EAC", 0x9273 },
-      { "GL_COMPRESSED_ALPHA_ARB", 0x84E9 },
-      { "GL_COMPRESSED_LUMINANCE_ARB", 0x84EA },
-      { "GL_COMPRESSED_LUMINANCE_ALPHA_ARB", 0x84EB },
-      { "GL_COMPRESSED_INTENSITY_ARB", 0x84EC },
-      { "GL_COMPRESSED_RGB_ARB", 0x84ED },
-      { "GL_COMPRESSED_RGBA_ARB", 0x84EE },
-      { "GL_COMPRESSED_TEXTURE_FORMATS_ARB", 0x86A3 },
-      { "GL_COMPRESSED_RGBA_BPTC_UNORM_ARB", 0x8E8C },
-      { "GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB", 0x8E8D },
-      { "GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB", 0x8E8E },
-      { "GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB", 0x8E8F },
-      { "GL_COMPRESSED_RGBA_ASTC_4x4_KHR", 0x93B0 },
-      { "GL_COMPRESSED_RGBA_ASTC_5x4_KHR", 0x93B1 },
-      { "GL_COMPRESSED_RGBA_ASTC_5x5_KHR", 0x93B2 },
-      { "GL_COMPRESSED_RGBA_ASTC_6x5_KHR", 0x93B3 },
-      { "GL_COMPRESSED_RGBA_ASTC_6x6_KHR", 0x93B4 },
-      { "GL_COMPRESSED_RGBA_ASTC_8x5_KHR", 0x93B5 },
-      { "GL_COMPRESSED_RGBA_ASTC_8x6_KHR", 0x93B6 },
-      { "GL_COMPRESSED_RGBA_ASTC_8x8_KHR", 0x93B7 },
-      { "GL_COMPRESSED_RGBA_ASTC_10x5_KHR", 0x93B8 },
-      { "GL_COMPRESSED_RGBA_ASTC_10x6_KHR", 0x93B9 },
-      { "GL_COMPRESSED_RGBA_ASTC_10x8_KHR", 0x93BA },
-      { "GL_COMPRESSED_RGBA_ASTC_10x10_KHR", 0x93BB },
-      { "GL_COMPRESSED_RGBA_ASTC_12x10_KHR", 0x93BC },
-      { "GL_COMPRESSED_RGBA_ASTC_12x12_KHR", 0x93BD },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR", 0x93D0 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR", 0x93D1 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR", 0x93D2 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR", 0x93D3 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR", 0x93D4 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR", 0x93D5 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR", 0x93D6 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR", 0x93D7 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR", 0x93D8 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR", 0x93D9 },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR", 0x93DA },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR", 0x93DB },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR", 0x93DC },
-      { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR", 0x93DD },
-      { "GL_COMPRESSED_RGB_FXT1_3DFX", 0x86B0 },
-      { "GL_COMPRESSED_RGBA_FXT1_3DFX", 0x86B1 },
-      { "GL_COMPRESSED_LUMINANCE_LATC1_EXT", 0x8C70 },
-      { "GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT", 0x8C71 },
-      { "GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT", 0x8C72 },
-      { "GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT", 0x8C73 },
-      { "GL_COMPRESSED_RED_RGTC1_EXT", 0x8DBB },
-      { "GL_COMPRESSED_SIGNED_RED_RGTC1_EXT", 0x8DBC },
-      { "GL_COMPRESSED_RED_GREEN_RGTC2_EXT", 0x8DBD },
-      { "GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT", 0x8DBE },
-      { "GL_COMPRESSED_RGB_S3TC_DXT1_EXT", 0x83F0 },
-      { "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT", 0x83F1 },
-      { "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT", 0x83F2 },
-      { "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT", 0x83F3 },
-      { "GL_COMPRESSED_SRGB_EXT", 0x8C48 },
-      { "GL_COMPRESSED_SRGB_ALPHA_EXT", 0x8C49 },
-      { "GL_COMPRESSED_SLUMINANCE_EXT", 0x8C4A },
-      { "GL_COMPRESSED_SLUMINANCE_ALPHA_EXT", 0x8C4B },
-      { "GL_COMPRESSED_SRGB_S3TC_DXT1_EXT", 0x8C4C },
-      { "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT", 0x8C4D },
-      { "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT", 0x8C4E },
-      { "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT", 0x8C4F },
-      { "GL_PALETTE4_RGB8_OES", 0x8B90 },
-      { "GL_PALETTE4_RGBA8_OES", 0x8B91 },
-      { "GL_PALETTE4_R5_G6_B5_OES", 0x8B92 },
-      { "GL_PALETTE4_RGBA4_OES", 0x8B93 },
-      { "GL_PALETTE4_RGB5_A1_OES", 0x8B94 },
-      { "GL_PALETTE8_RGB8_OES", 0x8B95 },
-      { "GL_PALETTE8_RGBA8_OES", 0x8B96 },
-      { "GL_PALETTE8_R5_G6_B5_OES", 0x8B97 },
-      { "GL_PALETTE8_RGBA4_OES", 0x8B98 },
-      { "GL_PALETTE8_RGB5_A1_OES", 0x8B99 }
-   };
-   const int n = sizeof(enums) / sizeof(enums[0]);
-   static char buffer[100];
-   int i;
-   for (i = 0; i < n; i++) {
-      if (enums[i].val == val) {
-         return enums[i].name;
-      }
-   }
-   /* enum val not found, just print hexadecimal value into static buffer */
-   sprintf(buffer, "0x%x", val);
-   return buffer;
-}
-
-
-/*
- * qsort callback for string comparison.
- */
-static int
-compare_string_ptr(const void *p1, const void *p2)
-{
-   return strcmp(* (char * const *) p1, * (char * const *) p2);
-}
-
-
-/*
- * Print a list of extensions, with word-wrapping.
- */
-static void
-print_extension_list(const char *ext, GLboolean singleLine)
-{
-   char **extensions;
-   int num_extensions;
-   const char *indentString = "    ";
-   const int indent = 4;
-   const int max = 79;
-   int width, i, j, k;
-
-   if (!ext || !ext[0])
-      return;
-
-   /* count the number of extensions, ignoring successive spaces */
-   num_extensions = 0;
-   j = 1;
-   do {
-      if ((ext[j] == ' ' || ext[j] == 0) && ext[j - 1] != ' ') {
-         ++num_extensions;
-      }
-   } while(ext[j++]);
-
-   /* copy individual extensions to an array */
-   extensions = malloc(num_extensions * sizeof *extensions);
-   if (!extensions) {
-      fprintf(stderr, "Error: malloc() failed\n");
-      exit(1);
-   }
-   i = j = k = 0;
-   while (1) {
-      if (ext[j] == ' ' || ext[j] == 0) {
-         /* found end of an extension name */
-         const int len = j - i;
-
-         if (len) {
-            assert(k < num_extensions);
-
-            extensions[k] = malloc(len + 1);
-            if (!extensions[k]) {
-               fprintf(stderr, "Error: malloc() failed\n");
-               exit(1);
-            }
-
-            memcpy(extensions[k], ext + i, len);
-            extensions[k][len] = 0;
-
-            ++k;
-         };
-
-         i += len + 1;
-
-         if (ext[j] == 0) {
-            break;
-         }
-      }
-      j++;
-   }
-   assert(k == num_extensions);
-
-   /* sort extensions alphabetically */
-   qsort(extensions, num_extensions, sizeof extensions[0], compare_string_ptr);
-
-   /* print the extensions */
-   width = indent;
-   printf("%s", indentString);
-   for (k = 0; k < num_extensions; ++k) {
-      const int len = strlen(extensions[k]);
-      if ((!singleLine) && (width + len > max)) {
-         /* start a new line */
-         printf("\n");
-         width = indent;
-         printf("%s", indentString);
-      }
-      /* print the extension name */
-      printf("%s", extensions[k]);
-
-      /* either we're all done, or we'll continue with next extension */
-      width += len + 1;
-
-      if (singleLine) {
-         printf("\n");
-         width = indent;
-         printf("%s", indentString);
-      }
-      else {
-         printf(", ");
-         width += 2;
-      }
-   }
-   printf("\n");
-
-   for (k = 0; k < num_extensions; ++k) {
-      free(extensions[k]);
-   }
-   free(extensions);
-}
-
-
-/**
- * Print interesting limits for vertex/fragment programs.
- */
-static void
-print_program_limits(GLenum target)
-{
-#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
-   struct token_name {
-      GLenum token;
-      const char *name;
-   };
-   static const struct token_name common_limits[] = {
-      { GL_MAX_PROGRAM_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_INSTRUCTIONS_ARB" },
-      { GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" },
-      { GL_MAX_PROGRAM_TEMPORARIES_ARB, "GL_MAX_PROGRAM_TEMPORARIES_ARB" },
-      { GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" },
-      { GL_MAX_PROGRAM_PARAMETERS_ARB, "GL_MAX_PROGRAM_PARAMETERS_ARB" },
-      { GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB" },
-      { GL_MAX_PROGRAM_ATTRIBS_ARB, "GL_MAX_PROGRAM_ATTRIBS_ARB" },
-      { GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB" },
-      { GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB" },
-      { GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" },
-      { GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB" },
-      { GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB" },
-      { (GLenum) 0, NULL }
-   };
-   static const struct token_name fragment_limits[] = {
-      { GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" },
-      { GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" },
-      { GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB" },
-      { GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" },
-      { GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" },
-      { GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" },
-      { (GLenum) 0, NULL }
-   };
-
-   PFNGLGETPROGRAMIVARBPROC GetProgramivARB_func = (PFNGLGETPROGRAMIVARBPROC)
-      wglGetProcAddress("glGetProgramivARB");
-
-   GLint max[1];
-   int i;
-
-   if (target == GL_VERTEX_PROGRAM_ARB) {
-      printf("    GL_VERTEX_PROGRAM_ARB:\n");
-   }
-   else if (target == GL_FRAGMENT_PROGRAM_ARB) {
-      printf("    GL_FRAGMENT_PROGRAM_ARB:\n");
-   }
-   else {
-      return; /* something's wrong */
-   }
-
-   for (i = 0; common_limits[i].token; i++) {
-      GetProgramivARB_func(target, common_limits[i].token, max);
-      if (glGetError() == GL_NO_ERROR) {
-         printf("        %s = %d\n", common_limits[i].name, max[0]);
-      }
-   }
-   if (target == GL_FRAGMENT_PROGRAM_ARB) {
-      for (i = 0; fragment_limits[i].token; i++) {
-         GetProgramivARB_func(target, fragment_limits[i].token, max);
-         if (glGetError() == GL_NO_ERROR) {
-            printf("        %s = %d\n", fragment_limits[i].name, max[0]);
-         }
-      }
-   }
-#endif /* GL_ARB_vertex_program / GL_ARB_fragment_program */
-}
-
-
-/**
- * Print interesting limits for vertex/fragment shaders.
- */
-static void
-print_shader_limits(GLenum target)
-{
-   struct token_name {
-      GLenum token;
-      const char *name;
-   };
-#if defined(GL_ARB_vertex_shader)
-   static const struct token_name vertex_limits[] = {
-      { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB" },
-      { GL_MAX_VARYING_FLOATS_ARB, "GL_MAX_VARYING_FLOATS_ARB" },
-      { GL_MAX_VERTEX_ATTRIBS_ARB, "GL_MAX_VERTEX_ATTRIBS_ARB" },
-      { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" },
-      { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" },
-      { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" },
-      { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" },
-      { (GLenum) 0, NULL }
-   };
-#endif
-#if defined(GL_ARB_fragment_shader)
-   static const struct token_name fragment_limits[] = {
-      { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" },
-      { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" },
-      { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" },
-      { (GLenum) 0, NULL }
-   };
-#endif
-   GLint max[1];
-   int i;
-
-#if defined(GL_ARB_vertex_shader)
-   if (target == GL_VERTEX_SHADER_ARB) {
-      printf("    GL_VERTEX_SHADER_ARB:\n");
-      for (i = 0; vertex_limits[i].token; i++) {
-         glGetIntegerv(vertex_limits[i].token, max);
-         if (glGetError() == GL_NO_ERROR) {
-            printf("        %s = %d\n", vertex_limits[i].name, max[0]);
-         }
-      }
-   }
-#endif
-#if defined(GL_ARB_fragment_shader)
-   if (target == GL_FRAGMENT_SHADER_ARB) {
-      printf("    GL_FRAGMENT_SHADER_ARB:\n");
-      for (i = 0; fragment_limits[i].token; i++) {
-         glGetIntegerv(fragment_limits[i].token, max);
-         if (glGetError() == GL_NO_ERROR) {
-            printf("        %s = %d\n", fragment_limits[i].name, max[0]);
-         }
-      }
-   }
-#endif
-}
-
-
-/** Is extension 'ext' supported? */
-static int
-extension_supported(const char *ext, const char *extensionsList)
-{
-   const char *p = strstr(extensionsList, ext);
-   if (p) {
-      /* check that next char is a space or end of string */
-      int extLen = strlen(ext);
-      if (p[extLen] == 0 || p[extLen] == ' ')
-         return 1;
-   }
-   return 0;
-}
-
-
-/**
- * Print interesting OpenGL implementation limits.
- */
-static void
-print_limits(const char *extensions)
-{
-   struct token_name {
-      GLuint count;
-      GLenum token;
-      const char *name;
-      const char *extension;
-   };
-   static const struct token_name limits[] = {
-      { 1, GL_MAX_ATTRIB_STACK_DEPTH, "GL_MAX_ATTRIB_STACK_DEPTH", NULL },
-      { 1, GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", NULL },
-      { 1, GL_MAX_CLIP_PLANES, "GL_MAX_CLIP_PLANES", NULL },
-      { 1, GL_MAX_COLOR_MATRIX_STACK_DEPTH, "GL_MAX_COLOR_MATRIX_STACK_DEPTH", "GL_ARB_imaging" },
-      { 1, GL_MAX_ELEMENTS_VERTICES, "GL_MAX_ELEMENTS_VERTICES", NULL },
-      { 1, GL_MAX_ELEMENTS_INDICES, "GL_MAX_ELEMENTS_INDICES", NULL },
-      { 1, GL_MAX_EVAL_ORDER, "GL_MAX_EVAL_ORDER", NULL },
-      { 1, GL_MAX_LIGHTS, "GL_MAX_LIGHTS", NULL },
-      { 1, GL_MAX_LIST_NESTING, "GL_MAX_LIST_NESTING", NULL },
-      { 1, GL_MAX_MODELVIEW_STACK_DEPTH, "GL_MAX_MODELVIEW_STACK_DEPTH", NULL },
-      { 1, GL_MAX_NAME_STACK_DEPTH, "GL_MAX_NAME_STACK_DEPTH", NULL },
-      { 1, GL_MAX_PIXEL_MAP_TABLE, "GL_MAX_PIXEL_MAP_TABLE", NULL },
-      { 1, GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH", NULL },
-      { 1, GL_MAX_TEXTURE_STACK_DEPTH, "GL_MAX_TEXTURE_STACK_DEPTH", NULL },
-      { 1, GL_MAX_TEXTURE_SIZE, "GL_MAX_TEXTURE_SIZE", NULL },
-      { 1, GL_MAX_3D_TEXTURE_SIZE, "GL_MAX_3D_TEXTURE_SIZE", NULL },
-      { 2, GL_MAX_VIEWPORT_DIMS, "GL_MAX_VIEWPORT_DIMS", NULL },
-      { 2, GL_ALIASED_LINE_WIDTH_RANGE, "GL_ALIASED_LINE_WIDTH_RANGE", NULL },
-      { 2, GL_SMOOTH_LINE_WIDTH_RANGE, "GL_SMOOTH_LINE_WIDTH_RANGE", NULL },
-      { 2, GL_ALIASED_POINT_SIZE_RANGE, "GL_ALIASED_POINT_SIZE_RANGE", NULL },
-      { 2, GL_SMOOTH_POINT_SIZE_RANGE, "GL_SMOOTH_POINT_SIZE_RANGE", NULL },
-#if defined(GL_ARB_texture_cube_map)
-      { 1, GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB", "GL_ARB_texture_cube_map" },
-#endif
-#if defined(GL_NV_texture_rectangle)
-      { 1, GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV", "GL_NV_texture_rectangle" },
-#endif
-#if defined(GL_ARB_multitexture)
-      { 1, GL_MAX_TEXTURE_UNITS_ARB, "GL_MAX_TEXTURE_UNITS_ARB", "GL_ARB_multitexture" },
-#endif
-#if defined(GL_EXT_texture_lod_bias)
-      { 1, GL_MAX_TEXTURE_LOD_BIAS_EXT, "GL_MAX_TEXTURE_LOD_BIAS_EXT", "GL_EXT_texture_lod_bias" },
-#endif
-#if defined(GL_EXT_texture_filter_anisotropic)
-      { 1, GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", "GL_EXT_texture_filter_anisotropic" },
-#endif
-#if defined(GL_ARB_draw_buffers)
-      { 1, GL_MAX_DRAW_BUFFERS_ARB, "GL_MAX_DRAW_BUFFERS_ARB", "GL_ARB_draw_buffers" },
-#endif
-#if defined(GL_ARB_blend_func_extended)
-      { 1, GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, "GL_MAX_DUAL_SOURCE_DRAW_BUFFERS", "GL_ARB_blend_func_extended" },
-#endif
-#if defined (GL_ARB_framebuffer_object)
-      { 1, GL_MAX_RENDERBUFFER_SIZE, "GL_MAX_RENDERBUFFER_SIZE", "GL_ARB_framebuffer_object" },
-      { 1, GL_MAX_COLOR_ATTACHMENTS, "GL_MAX_COLOR_ATTACHMENTS", "GL_ARB_framebuffer_object" },
-      { 1, GL_MAX_SAMPLES, "GL_MAX_SAMPLES", "GL_ARB_framebuffer_object" },
-#endif
-      { 0, (GLenum) 0, NULL, NULL }
-   };
-   GLint i, max[2];
-
-   printf("OpenGL limits:\n");
-   for (i = 0; limits[i].count; i++) {
-      if (!limits[i].extension ||
-          extension_supported(limits[i].extension, extensions)) {
-         glGetIntegerv(limits[i].token, max);
-         if (glGetError() == GL_NO_ERROR) {
-            if (limits[i].count == 1)
-               printf("    %s = %d\n", limits[i].name, max[0]);
-            else /* XXX fix if we ever query something with more than 2 values */
-               printf("    %s = %d, %d\n", limits[i].name, max[0], max[1]);
-         }
-      }
-   }
-
-   /* these don't fit into the above mechanism, unfortunately */
-#if defined(GL_EXT_convolution)
-   if (extension_supported("GL_ARB_imaging", extensions)) {
-      PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC glGetConvolutionParameterivEXT_func = 
-         (PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC)wglGetProcAddress("glGetConvolutionParameterivEXT");
-      if(glGetConvolutionParameterivEXT_func) {
-         /* these don't fit into the above mechanism, unfortunately */
-         glGetConvolutionParameterivEXT_func(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_WIDTH, max);
-         glGetConvolutionParameterivEXT_func(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_HEIGHT, max+1);
-         if (glGetError() == GL_NONE) {
-            printf("    GL_MAX_CONVOLUTION_WIDTH/HEIGHT = %d, %d\n", max[0], max[1]);
-         }
-      }
-   }
-#endif
-
-   if (extension_supported("GL_ARB_texture_compression", extensions)) {
-      GLint i, n;
-      GLint *formats;
-      glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &n);
-      printf("    GL_NUM_COMPRESSED_TEXTURE_FORMATS = %d\n", n);
-      formats = (GLint *) malloc(n * sizeof(GLint));
-      glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
-      for (i = 0; i < n; i++) {
-         printf("        %s\n", enum_name(formats[i]));
-      }
-      free(formats);
-   }
-
-#if defined(GL_ARB_vertex_program)
-   if (extension_supported("GL_ARB_vertex_program", extensions)) {
-      print_program_limits(GL_VERTEX_PROGRAM_ARB);
-   }
-#endif
-#if defined(GL_ARB_fragment_program)
-   if (extension_supported("GL_ARB_fragment_program", extensions)) {
-      print_program_limits(GL_FRAGMENT_PROGRAM_ARB);
-   }
-#endif
-#if defined(GL_ARB_vertex_shader)
-   if (extension_supported("GL_ARB_vertex_shader", extensions)) {
-      print_shader_limits(GL_VERTEX_SHADER_ARB);
-   }
-#endif
-#if defined(GL_ARB_fragment_shader)
-   if (extension_supported("GL_ARB_fragment_shader", extensions)) {
-      print_shader_limits(GL_FRAGMENT_SHADER_ARB);
-   }
-#endif
-}
-
 
 static LRESULT CALLBACK
 WndProc(HWND hWnd,
@@ -591,6 +78,8 @@ print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine)
    int visinfo;
    HDC hdc;
    PIXELFORMATDESCRIPTOR pfd;
+   int version;
+   const char *oglString = "OpenGL";
 
    memset(&wc, 0, sizeof wc);
    wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
@@ -661,6 +150,7 @@ print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine)
       const char *glRenderer = (const char *) glGetString(GL_RENDERER);
       const char *glVersion = (const char *) glGetString(GL_VERSION);
       const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS);
+      struct ext_functions extfuncs;
       
 #if defined(WGL_ARB_extensions_string)
       if (wglGetExtensionsStringARB_func) {
@@ -681,10 +171,20 @@ print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine)
       }
 #endif
 
+      extfuncs.GetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)
+         wglGetProcAddress("glGetProgramivARB");
+      extfuncs.GetStringi = (PFNGLGETSTRINGIPROC)
+         wglGetProcAddress("glGetStringi");
+      extfuncs.GetConvolutionParameteriv = (GETCONVOLUTIONPARAMETERIVPROC)
+         wglGetProcAddress("glGetConvolutionParameteriv");
+
+      version = (glVersion[0] - '0') * 10 + (glVersion[2] - '0');
+
       printf("OpenGL extensions:\n");
       print_extension_list(glExtensions, singleLine);
-      if (limits)
-         print_limits(glExtensions);
+      if (limits) {
+         print_limits(glExtensions, oglString, version, &extfuncs);
+      }
    }
    else {
       fprintf(stderr, "Error: wglMakeCurrent failed\n");
-- 
1.7.10.4



More information about the mesa-dev mailing list