Skip to content

Latest commit

 

History

History
163 lines (133 loc) · 4.87 KB

glcaps.c

File metadata and controls

163 lines (133 loc) · 4.87 KB
 
May 3, 2008
May 3, 2008
1
2
3
4
5
6
#ifdef _WINDOWS
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#include <stdio.h>
May 3, 2008
May 3, 2008
7
#define GL_GLEXT_LEGACY 1
May 3, 2008
May 3, 2008
8
9
10
11
#include "GL/gl.h"
#include "GL/glext.h"
#include "SDL.h"
May 3, 2008
May 3, 2008
12
13
14
15
#ifndef WINGDIAPI
#define WINGDIAPI
#endif
May 3, 2008
May 3, 2008
16
typedef WINGDIAPI void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params);
May 3, 2008
May 3, 2008
17
18
typedef WINGDIAPI const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
May 3, 2008
May 3, 2008
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT
#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2
#endif
#ifndef GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT
#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3
#endif
#ifndef GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT
#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4
#endif
#ifndef GL_MAX_BINDABLE_UNIFORM_SIZE_EXT
#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED
#endif
Feb 21, 2014
Feb 21, 2014
32
33
34
35
36
37
static int is_atleast_gl3(const char *str)
{
int maj, min;
sscanf(str, "%d.%d", &maj, &min);
return ( ((maj << 16) | min) >= ((3 << 16) | 0) );
}
May 3, 2008
May 3, 2008
38
May 3, 2008
May 3, 2008
39
40
int main(int argc, char **argv)
{
Feb 21, 2014
Feb 21, 2014
41
int retval = 1;
May 3, 2008
May 3, 2008
42
GLint val = 0;
Jun 29, 2008
Jun 29, 2008
43
const char *str = NULL;
Feb 21, 2014
Feb 21, 2014
44
SDL_Window *sdlwindow = NULL;
May 3, 2008
May 3, 2008
45
Feb 21, 2014
Feb 21, 2014
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
if (SDL_Init(SDL_INIT_VIDEO) == -1)
fprintf(stderr, "SDL_Init() error: %s\n", SDL_GetError());
else if (SDL_GL_LoadLibrary(NULL) == -1)
fprintf(stderr, "SDL_GL_LoadLibrary() error: %s\n", SDL_GetError());
else if ((sdlwindow = SDL_CreateWindow(argv[0], SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_OPENGL)) == NULL)
fprintf(stderr, "SDL_CreateWindow() error: %s\n", SDL_GetError());
if (SDL_GL_CreateContext(sdlwindow) == NULL)
fprintf(stderr, "SDL_GL_CreateContext() error: %s\n", SDL_GetError());
else
retval = 0;
if (retval != 0)
{
SDL_Quit();
return retval;
} // if
May 3, 2008
May 3, 2008
62
63
64
65
PFNGLGETSTRINGPROC pglGetString = (PFNGLGETSTRINGPROC) SDL_GL_GetProcAddress("glGetString");
PFNGLGETINTEGERVPROC pglGetIntegerv = (PFNGLGETINTEGERVPROC) SDL_GL_GetProcAddress("glGetIntegerv");
PFNGLGETPROGRAMIVARBPROC pglGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) SDL_GL_GetProcAddress("glGetProgramivARB");
Feb 21, 2014
Feb 21, 2014
66
PFNGLGETSTRINGIPROC pglGetStringi = (PFNGLGETSTRINGIPROC) SDL_GL_GetProcAddress("glGetStringi");
May 3, 2008
May 3, 2008
67
68
69
70
71
72
73
74
75
76
77
78
79
printf("Basic strings...\n\n");
#define getval(x) printf(#x ": %s\n", pglGetString(x))
getval(GL_RENDERER);
getval(GL_VERSION);
getval(GL_VENDOR);
#undef getval
printf("\nExtensions...\n\n");
Feb 21, 2014
Feb 21, 2014
80
if (is_atleast_gl3((const char *) pglGetString(GL_VERSION)))
May 3, 2008
May 3, 2008
81
{
Feb 21, 2014
Feb 21, 2014
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
GLint i;
GLint num_exts = 0;
pglGetIntegerv(GL_NUM_EXTENSIONS, &num_exts);
for (i = 0; i < num_exts; i++)
printf("%s\n", (const char *) pglGetStringi(GL_EXTENSIONS, i));
}
else
{
const GLubyte *ext = pglGetString(GL_EXTENSIONS);
while (*ext)
{
fputc((*ext == ' ') ? '\n' : ((int) *ext), stdout);
ext++;
} // while
ext--;
if (*ext != ' ')
printf("\n");
}
May 3, 2008
May 3, 2008
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
printf("\nARB1 values...\n\n");
if (pglGetProgramivARB == NULL)
printf(" (unsupported.)\n");
else
{
#define getval(x) \
val = -1; \
pglGetProgramivARB(GL_VERTEX_PROGRAM_ARB, x, &val); \
printf(#x ": %d\n", (int) val);
getval(GL_MAX_PROGRAM_INSTRUCTIONS_ARB);
getval(GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB);
getval(GL_MAX_PROGRAM_TEMPORARIES_ARB);
getval(GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB);
getval(GL_MAX_PROGRAM_PARAMETERS_ARB);
getval(GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB);
getval(GL_MAX_PROGRAM_ATTRIBS_ARB);
getval(GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB);
getval(GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB);
getval(GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB);
getval(GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB);
getval(GL_MAX_PROGRAM_ENV_PARAMETERS_ARB);
getval(GL_MAX_PROGRAM_PARAMETERS_ARB);
#undef getval
} // else
printf("\nGLSL values...\n\n");
#define getval(x) \
val = -1; \
pglGetIntegerv(x, &val); \
printf(#x ": %d\n", (int) val);
Jun 29, 2008
Jun 29, 2008
137
138
str = (const char *) pglGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
printf("GL_SHADING_LANGUAGE_VERSION_ARB: %s\n", str);
May 3, 2008
May 3, 2008
139
140
getval(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB);
getval(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB);
May 3, 2008
May 3, 2008
141
142
143
144
145
146
getval(GL_MAX_VARYING_FLOATS_ARB);
getval(GL_MAX_VERTEX_ATTRIBS_ARB);
getval(GL_MAX_TEXTURE_IMAGE_UNITS_ARB);
getval(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB);
getval(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB);
getval(GL_MAX_TEXTURE_COORDS_ARB);
May 3, 2008
May 3, 2008
147
May 3, 2008
May 3, 2008
148
149
150
151
152
153
154
printf("\nGL_EXT_bindable_uniform values...\n\n");
getval(GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT);
getval(GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT);
getval(GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT);
getval(GL_MAX_BINDABLE_UNIFORM_SIZE_EXT);
May 3, 2008
May 3, 2008
155
156
157
158
159
160
161
#undef getval
SDL_Quit();
printf("\n");
return 0;
}