glcaps.c
branchtrunk
changeset 269 fbc4e1843809
child 271 a9f0f4a1d9a9
equal deleted inserted replaced
268:6d5a1323db28 269:fbc4e1843809
       
     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_PROTOTYPES 1
       
     8 #include "GL/gl.h"
       
     9 #include "GL/glext.h"
       
    10 #include "SDL.h"
       
    11 
       
    12 typedef WINGDIAPI const GLubyte * (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params);
       
    13 typedef WINGDIAPI const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
       
    14 
       
    15 int main(int argc, char **argv)
       
    16 {
       
    17     GLint val = 0;
       
    18 
       
    19     SDL_Init(SDL_INIT_VIDEO);
       
    20     SDL_GL_LoadLibrary(NULL);
       
    21     SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
       
    22 
       
    23     PFNGLGETSTRINGPROC pglGetString = (PFNGLGETSTRINGPROC) SDL_GL_GetProcAddress("glGetString");
       
    24     PFNGLGETINTEGERVPROC pglGetIntegerv = (PFNGLGETINTEGERVPROC) SDL_GL_GetProcAddress("glGetIntegerv");
       
    25     PFNGLGETPROGRAMIVARBPROC pglGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) SDL_GL_GetProcAddress("glGetProgramivARB");
       
    26 
       
    27     printf("Basic strings...\n\n");
       
    28 
       
    29     #define getval(x) printf(#x ": %s\n", pglGetString(x))
       
    30 
       
    31     getval(GL_RENDERER);
       
    32     getval(GL_VERSION);
       
    33     getval(GL_VENDOR);
       
    34 
       
    35     #undef getval
       
    36 
       
    37     printf("\nExtensions...\n\n");
       
    38 
       
    39     const GLubyte *ext = pglGetString(GL_EXTENSIONS);
       
    40     while (*ext)
       
    41     {
       
    42         fputc((*ext == ' ') ? '\n' : ((int) *ext), stdout);
       
    43         ext++;
       
    44     } // while
       
    45 
       
    46     ext--;
       
    47     if (*ext != ' ')
       
    48         printf("\n");
       
    49 
       
    50     printf("\nARB1 values...\n\n");
       
    51 
       
    52     if (pglGetProgramivARB == NULL)
       
    53         printf("  (unsupported.)\n");
       
    54     else
       
    55     {
       
    56         #define getval(x) \
       
    57             val = -1; \
       
    58             pglGetProgramivARB(GL_VERTEX_PROGRAM_ARB, x, &val); \
       
    59             printf(#x ": %d\n", (int) val);
       
    60 
       
    61         getval(GL_MAX_PROGRAM_INSTRUCTIONS_ARB);
       
    62         getval(GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB);
       
    63         getval(GL_MAX_PROGRAM_TEMPORARIES_ARB);
       
    64         getval(GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB);
       
    65         getval(GL_MAX_PROGRAM_PARAMETERS_ARB);
       
    66         getval(GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB);
       
    67         getval(GL_MAX_PROGRAM_ATTRIBS_ARB);
       
    68         getval(GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB);
       
    69         getval(GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB);
       
    70         getval(GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB);
       
    71         getval(GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB);
       
    72         getval(GL_MAX_PROGRAM_ENV_PARAMETERS_ARB);
       
    73         getval(GL_MAX_PROGRAM_PARAMETERS_ARB);
       
    74 
       
    75         #undef getval
       
    76     } // else
       
    77 
       
    78     printf("\nGLSL values...\n\n");
       
    79 
       
    80     #define getval(x) \
       
    81         val = -1; \
       
    82         pglGetIntegerv(x, &val); \
       
    83         printf(#x ": %d\n", (int) val);
       
    84 
       
    85     getval(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB);
       
    86     getval(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB);
       
    87     getval(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB);
       
    88 	getval(GL_MAX_VARYING_FLOATS_ARB);
       
    89 	getval(GL_MAX_VERTEX_ATTRIBS_ARB);
       
    90 	getval(GL_MAX_TEXTURE_IMAGE_UNITS_ARB);
       
    91 	getval(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB);
       
    92 	getval(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB);
       
    93 	getval(GL_MAX_TEXTURE_COORDS_ARB);
       
    94 
       
    95     #undef getval
       
    96 
       
    97     SDL_Quit();
       
    98     printf("\n");
       
    99 
       
   100     return 0;
       
   101 }
       
   102 
       
   103