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