glcaps.c
author Ryan C. Gordon <icculus@icculus.org>
Sat, 03 May 2008 13:42:47 -0400
branchtrunk
changeset 276 1d7437469c94
parent 275 cd25ba040c5e
child 277 49a6571cac6d
permissions -rw-r--r--
Added MOJOSHADER_glMaxUniforms().
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>
272
951e5cecbd99 Patched to compile on Mac OS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 271
diff changeset
     7
#define GL_GLEXT_LEGACY 1
269
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
275
cd25ba040c5e Whoops, glGetIntegerv() returns void. Cut-and-paste error!
Ryan C. Gordon <icculus@icculus.org>
parents: 274
diff changeset
    12
typedef WINGDIAPI void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params);
269
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
271
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    15
#ifndef GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    16
#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    17
#endif
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    18
#ifndef GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    19
#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    20
#endif
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    21
#ifndef GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    22
#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    23
#endif
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    24
#ifndef GL_MAX_BINDABLE_UNIFORM_SIZE_EXT
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    25
#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    26
#endif
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    27
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
    28
269
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
int main(int argc, char **argv)
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
    GLint val = 0;
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
    SDL_Init(SDL_INIT_VIDEO);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
    SDL_GL_LoadLibrary(NULL);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
    SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
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
    PFNGLGETSTRINGPROC pglGetString = (PFNGLGETSTRINGPROC) SDL_GL_GetProcAddress("glGetString");
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
    PFNGLGETINTEGERVPROC pglGetIntegerv = (PFNGLGETINTEGERVPROC) SDL_GL_GetProcAddress("glGetIntegerv");
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
    PFNGLGETPROGRAMIVARBPROC pglGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) SDL_GL_GetProcAddress("glGetProgramivARB");
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
    printf("Basic strings...\n\n");
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
    #define getval(x) printf(#x ": %s\n", pglGetString(x))
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
    getval(GL_RENDERER);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
    getval(GL_VERSION);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
    getval(GL_VENDOR);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
    #undef getval
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
    printf("\nExtensions...\n\n");
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
    const GLubyte *ext = pglGetString(GL_EXTENSIONS);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
    while (*ext)
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
        fputc((*ext == ' ') ? '\n' : ((int) *ext), stdout);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
        ext++;
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
    } // while
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
    ext--;
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
    if (*ext != ' ')
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
        printf("\n");
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
    printf("\nARB1 values...\n\n");
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
    if (pglGetProgramivARB == NULL)
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
        printf("  (unsupported.)\n");
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
    else
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
    {
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
        #define getval(x) \
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
            val = -1; \
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
            pglGetProgramivARB(GL_VERTEX_PROGRAM_ARB, x, &val); \
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
            printf(#x ": %d\n", (int) val);
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
        getval(GL_MAX_PROGRAM_INSTRUCTIONS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
        getval(GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
        getval(GL_MAX_PROGRAM_TEMPORARIES_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
        getval(GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
        getval(GL_MAX_PROGRAM_PARAMETERS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
        getval(GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
        getval(GL_MAX_PROGRAM_ATTRIBS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
        getval(GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
        getval(GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
        getval(GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
        getval(GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
        getval(GL_MAX_PROGRAM_ENV_PARAMETERS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
        getval(GL_MAX_PROGRAM_PARAMETERS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
        #undef getval
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
    } // else
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
    printf("\nGLSL values...\n\n");
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
    #define getval(x) \
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
        val = -1; \
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
        pglGetIntegerv(x, &val); \
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
        printf(#x ": %d\n", (int) val);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
    getval(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB);
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
    getval(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB);
274
857f2198d5a9 Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents: 273
diff changeset
   101
    getval(GL_MAX_VARYING_FLOATS_ARB);
857f2198d5a9 Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents: 273
diff changeset
   102
    getval(GL_MAX_VERTEX_ATTRIBS_ARB);
857f2198d5a9 Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents: 273
diff changeset
   103
    getval(GL_MAX_TEXTURE_IMAGE_UNITS_ARB);
857f2198d5a9 Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents: 273
diff changeset
   104
    getval(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB);
857f2198d5a9 Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents: 273
diff changeset
   105
    getval(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB);
857f2198d5a9 Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents: 273
diff changeset
   106
    getval(GL_MAX_TEXTURE_COORDS_ARB);
269
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
271
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
   108
    printf("\nGL_EXT_bindable_uniform values...\n\n");
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
   109
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
   110
    getval(GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT);
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
   111
    getval(GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT);
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
   112
    getval(GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT);
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
   113
    getval(GL_MAX_BINDABLE_UNIFORM_SIZE_EXT);
a9f0f4a1d9a9 Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 269
diff changeset
   114
269
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
    #undef getval
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
    SDL_Quit();
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
    printf("\n");
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
    return 0;
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
}
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
fbc4e1843809 Added glcaps.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123