utils/glcaps.c
changeset 588 ef3d2efa822d
parent 412 4e275a0788f7
child 1134 be31bd0ee0a2
equal deleted inserted replaced
587:202354e004fc 588:ef3d2efa822d
       
     1 #ifdef _WINDOWS
       
     2 #define WIN32_LEAN_AND_MEAN 1
       
     3 #include <windows.h>
       
     4 #endif
       
     5 
       
     6 #include <stdio.h>
       
     7 #define GL_GLEXT_LEGACY 1
       
     8 #include "GL/gl.h"
       
     9 #include "GL/glext.h"
       
    10 #include "SDL.h"
       
    11 
       
    12 #ifndef WINGDIAPI
       
    13 #define WINGDIAPI
       
    14 #endif
       
    15 
       
    16 typedef WINGDIAPI void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params);
       
    17 typedef WINGDIAPI const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
       
    18 
       
    19 #ifndef GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT
       
    20 #define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2
       
    21 #endif
       
    22 #ifndef GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT
       
    23 #define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3
       
    24 #endif
       
    25 #ifndef GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT
       
    26 #define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4
       
    27 #endif
       
    28 #ifndef GL_MAX_BINDABLE_UNIFORM_SIZE_EXT
       
    29 #define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED
       
    30 #endif
       
    31 
       
    32 
       
    33 int main(int argc, char **argv)
       
    34 {
       
    35     GLint val = 0;
       
    36     const char *str = NULL;
       
    37 
       
    38     SDL_Init(SDL_INIT_VIDEO);
       
    39     SDL_GL_LoadLibrary(NULL);
       
    40     SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
       
    41 
       
    42     PFNGLGETSTRINGPROC pglGetString = (PFNGLGETSTRINGPROC) SDL_GL_GetProcAddress("glGetString");
       
    43     PFNGLGETINTEGERVPROC pglGetIntegerv = (PFNGLGETINTEGERVPROC) SDL_GL_GetProcAddress("glGetIntegerv");
       
    44     PFNGLGETPROGRAMIVARBPROC pglGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) SDL_GL_GetProcAddress("glGetProgramivARB");
       
    45 
       
    46     printf("Basic strings...\n\n");
       
    47 
       
    48     #define getval(x) printf(#x ": %s\n", pglGetString(x))
       
    49 
       
    50     getval(GL_RENDERER);
       
    51     getval(GL_VERSION);
       
    52     getval(GL_VENDOR);
       
    53 
       
    54     #undef getval
       
    55 
       
    56     printf("\nExtensions...\n\n");
       
    57 
       
    58     const GLubyte *ext = pglGetString(GL_EXTENSIONS);
       
    59     while (*ext)
       
    60     {
       
    61         fputc((*ext == ' ') ? '\n' : ((int) *ext), stdout);
       
    62         ext++;
       
    63     } // while
       
    64 
       
    65     ext--;
       
    66     if (*ext != ' ')
       
    67         printf("\n");
       
    68 
       
    69     printf("\nARB1 values...\n\n");
       
    70 
       
    71     if (pglGetProgramivARB == NULL)
       
    72         printf("  (unsupported.)\n");
       
    73     else
       
    74     {
       
    75         #define getval(x) \
       
    76             val = -1; \
       
    77             pglGetProgramivARB(GL_VERTEX_PROGRAM_ARB, x, &val); \
       
    78             printf(#x ": %d\n", (int) val);
       
    79 
       
    80         getval(GL_MAX_PROGRAM_INSTRUCTIONS_ARB);
       
    81         getval(GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB);
       
    82         getval(GL_MAX_PROGRAM_TEMPORARIES_ARB);
       
    83         getval(GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB);
       
    84         getval(GL_MAX_PROGRAM_PARAMETERS_ARB);
       
    85         getval(GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB);
       
    86         getval(GL_MAX_PROGRAM_ATTRIBS_ARB);
       
    87         getval(GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB);
       
    88         getval(GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB);
       
    89         getval(GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB);
       
    90         getval(GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB);
       
    91         getval(GL_MAX_PROGRAM_ENV_PARAMETERS_ARB);
       
    92         getval(GL_MAX_PROGRAM_PARAMETERS_ARB);
       
    93 
       
    94         #undef getval
       
    95     } // else
       
    96 
       
    97     printf("\nGLSL values...\n\n");
       
    98 
       
    99     #define getval(x) \
       
   100         val = -1; \
       
   101         pglGetIntegerv(x, &val); \
       
   102         printf(#x ": %d\n", (int) val);
       
   103 
       
   104     str = (const char *) pglGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
       
   105     printf("GL_SHADING_LANGUAGE_VERSION_ARB: %s\n", str);
       
   106     getval(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB);
       
   107     getval(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB);
       
   108     getval(GL_MAX_VARYING_FLOATS_ARB);
       
   109     getval(GL_MAX_VERTEX_ATTRIBS_ARB);
       
   110     getval(GL_MAX_TEXTURE_IMAGE_UNITS_ARB);
       
   111     getval(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB);
       
   112     getval(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB);
       
   113     getval(GL_MAX_TEXTURE_COORDS_ARB);
       
   114 
       
   115     printf("\nGL_EXT_bindable_uniform values...\n\n");
       
   116 
       
   117     getval(GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT);
       
   118     getval(GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT);
       
   119     getval(GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT);
       
   120     getval(GL_MAX_BINDABLE_UNIFORM_SIZE_EXT);
       
   121 
       
   122     #undef getval
       
   123 
       
   124     SDL_Quit();
       
   125     printf("\n");
       
   126 
       
   127     return 0;
       
   128 }
       
   129 
       
   130