author | Ryan C. Gordon <icculus@icculus.org> |
Sat, 26 Sep 2015 23:34:00 -0400 | |
changeset 1147 | ff14a55da268 |
parent 1135 | 780e3e4b1d4a |
permissions | -rw-r--r-- |
269 | 1 |
#ifdef _WINDOWS |
2 |
#define WIN32_LEAN_AND_MEAN 1 |
|
3 |
#include <windows.h> |
|
4 |
#endif |
|
5 |
||
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 | 8 |
#include "GL/gl.h" |
9 |
#include "GL/glext.h" |
|
10 |
#include "SDL.h" |
|
11 |
||
277
49a6571cac6d
Patched to compile on older (?) GL headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
275
diff
changeset
|
12 |
#ifndef WINGDIAPI |
49a6571cac6d
Patched to compile on older (?) GL headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
275
diff
changeset
|
13 |
#define WINGDIAPI |
49a6571cac6d
Patched to compile on older (?) GL headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
275
diff
changeset
|
14 |
#endif |
49a6571cac6d
Patched to compile on older (?) GL headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
275
diff
changeset
|
15 |
|
275
cd25ba040c5e
Whoops, glGetIntegerv() returns void. Cut-and-paste error!
Ryan C. Gordon <icculus@icculus.org>
parents:
274
diff
changeset
|
16 |
typedef WINGDIAPI void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); |
269 | 17 |
typedef WINGDIAPI const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); |
18 |
||
271
a9f0f4a1d9a9
Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents:
269
diff
changeset
|
19 |
#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
|
20 |
#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
|
21 |
#endif |
a9f0f4a1d9a9
Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents:
269
diff
changeset
|
22 |
#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
|
23 |
#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
|
24 |
#endif |
a9f0f4a1d9a9
Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents:
269
diff
changeset
|
25 |
#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
|
26 |
#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
|
27 |
#endif |
a9f0f4a1d9a9
Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents:
269
diff
changeset
|
28 |
#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
|
29 |
#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
|
30 |
#endif |
a9f0f4a1d9a9
Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents:
269
diff
changeset
|
31 |
|
1135
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
32 |
static int is_atleast_gl3(const char *str) |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
33 |
{ |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
34 |
int maj, min; |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
35 |
sscanf(str, "%d.%d", &maj, &min); |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
36 |
return ( ((maj << 16) | min) >= ((3 << 16) | 0) ); |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
37 |
} |
271
a9f0f4a1d9a9
Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents:
269
diff
changeset
|
38 |
|
269 | 39 |
int main(int argc, char **argv) |
40 |
{ |
|
1134 | 41 |
int retval = 1; |
269 | 42 |
GLint val = 0; |
412
4e275a0788f7
Added test for GLSL version string.
Ryan C. Gordon <icculus@icculus.org>
parents:
277
diff
changeset
|
43 |
const char *str = NULL; |
1134 | 44 |
SDL_Window *sdlwindow = NULL; |
269 | 45 |
|
1134 | 46 |
if (SDL_Init(SDL_INIT_VIDEO) == -1) |
47 |
fprintf(stderr, "SDL_Init() error: %s\n", SDL_GetError()); |
|
48 |
else if (SDL_GL_LoadLibrary(NULL) == -1) |
|
49 |
fprintf(stderr, "SDL_GL_LoadLibrary() error: %s\n", SDL_GetError()); |
|
50 |
else if ((sdlwindow = SDL_CreateWindow(argv[0], SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_OPENGL)) == NULL) |
|
51 |
fprintf(stderr, "SDL_CreateWindow() error: %s\n", SDL_GetError()); |
|
52 |
if (SDL_GL_CreateContext(sdlwindow) == NULL) |
|
53 |
fprintf(stderr, "SDL_GL_CreateContext() error: %s\n", SDL_GetError()); |
|
54 |
else |
|
55 |
retval = 0; |
|
56 |
||
57 |
if (retval != 0) |
|
58 |
{ |
|
59 |
SDL_Quit(); |
|
60 |
return retval; |
|
61 |
} // if |
|
269 | 62 |
|
63 |
PFNGLGETSTRINGPROC pglGetString = (PFNGLGETSTRINGPROC) SDL_GL_GetProcAddress("glGetString"); |
|
64 |
PFNGLGETINTEGERVPROC pglGetIntegerv = (PFNGLGETINTEGERVPROC) SDL_GL_GetProcAddress("glGetIntegerv"); |
|
65 |
PFNGLGETPROGRAMIVARBPROC pglGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) SDL_GL_GetProcAddress("glGetProgramivARB"); |
|
1135
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
66 |
PFNGLGETSTRINGIPROC pglGetStringi = (PFNGLGETSTRINGIPROC) SDL_GL_GetProcAddress("glGetStringi"); |
269 | 67 |
|
68 |
printf("Basic strings...\n\n"); |
|
69 |
||
70 |
#define getval(x) printf(#x ": %s\n", pglGetString(x)) |
|
71 |
||
72 |
getval(GL_RENDERER); |
|
73 |
getval(GL_VERSION); |
|
74 |
getval(GL_VENDOR); |
|
75 |
||
76 |
#undef getval |
|
77 |
||
78 |
printf("\nExtensions...\n\n"); |
|
79 |
||
1135
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
80 |
if (is_atleast_gl3((const char *) pglGetString(GL_VERSION))) |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
81 |
{ |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
82 |
GLint i; |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
83 |
GLint num_exts = 0; |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
84 |
pglGetIntegerv(GL_NUM_EXTENSIONS, &num_exts); |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
85 |
for (i = 0; i < num_exts; i++) |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
86 |
printf("%s\n", (const char *) pglGetStringi(GL_EXTENSIONS, i)); |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
87 |
} |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
88 |
else |
269 | 89 |
{ |
1135
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
90 |
const GLubyte *ext = pglGetString(GL_EXTENSIONS); |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
91 |
while (*ext) |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
92 |
{ |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
93 |
fputc((*ext == ' ') ? '\n' : ((int) *ext), stdout); |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
94 |
ext++; |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
95 |
} // while |
269 | 96 |
|
1135
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
97 |
ext--; |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
98 |
if (*ext != ' ') |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
99 |
printf("\n"); |
780e3e4b1d4a
Support OpenGL 3.0 and later.
Ryan C. Gordon <icculus@icculus.org>
parents:
1134
diff
changeset
|
100 |
} |
269 | 101 |
|
102 |
printf("\nARB1 values...\n\n"); |
|
103 |
||
104 |
if (pglGetProgramivARB == NULL) |
|
105 |
printf(" (unsupported.)\n"); |
|
106 |
else |
|
107 |
{ |
|
108 |
#define getval(x) \ |
|
109 |
val = -1; \ |
|
110 |
pglGetProgramivARB(GL_VERTEX_PROGRAM_ARB, x, &val); \ |
|
111 |
printf(#x ": %d\n", (int) val); |
|
112 |
||
113 |
getval(GL_MAX_PROGRAM_INSTRUCTIONS_ARB); |
|
114 |
getval(GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB); |
|
115 |
getval(GL_MAX_PROGRAM_TEMPORARIES_ARB); |
|
116 |
getval(GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB); |
|
117 |
getval(GL_MAX_PROGRAM_PARAMETERS_ARB); |
|
118 |
getval(GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB); |
|
119 |
getval(GL_MAX_PROGRAM_ATTRIBS_ARB); |
|
120 |
getval(GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB); |
|
121 |
getval(GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB); |
|
122 |
getval(GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB); |
|
123 |
getval(GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB); |
|
124 |
getval(GL_MAX_PROGRAM_ENV_PARAMETERS_ARB); |
|
125 |
getval(GL_MAX_PROGRAM_PARAMETERS_ARB); |
|
126 |
||
127 |
#undef getval |
|
128 |
} // else |
|
129 |
||
130 |
printf("\nGLSL values...\n\n"); |
|
131 |
||
132 |
#define getval(x) \ |
|
133 |
val = -1; \ |
|
134 |
pglGetIntegerv(x, &val); \ |
|
135 |
printf(#x ": %d\n", (int) val); |
|
136 |
||
412
4e275a0788f7
Added test for GLSL version string.
Ryan C. Gordon <icculus@icculus.org>
parents:
277
diff
changeset
|
137 |
str = (const char *) pglGetString(GL_SHADING_LANGUAGE_VERSION_ARB); |
4e275a0788f7
Added test for GLSL version string.
Ryan C. Gordon <icculus@icculus.org>
parents:
277
diff
changeset
|
138 |
printf("GL_SHADING_LANGUAGE_VERSION_ARB: %s\n", str); |
269 | 139 |
getval(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB); |
140 |
getval(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB); |
|
274
857f2198d5a9
Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents:
273
diff
changeset
|
141 |
getval(GL_MAX_VARYING_FLOATS_ARB); |
857f2198d5a9
Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents:
273
diff
changeset
|
142 |
getval(GL_MAX_VERTEX_ATTRIBS_ARB); |
857f2198d5a9
Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents:
273
diff
changeset
|
143 |
getval(GL_MAX_TEXTURE_IMAGE_UNITS_ARB); |
857f2198d5a9
Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents:
273
diff
changeset
|
144 |
getval(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB); |
857f2198d5a9
Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents:
273
diff
changeset
|
145 |
getval(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB); |
857f2198d5a9
Removed tab characters from source.
Ryan C. Gordon <icculus@icculus.org>
parents:
273
diff
changeset
|
146 |
getval(GL_MAX_TEXTURE_COORDS_ARB); |
269 | 147 |
|
271
a9f0f4a1d9a9
Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents:
269
diff
changeset
|
148 |
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
|
149 |
|
a9f0f4a1d9a9
Research on GL_EXT_bindable_uniform for future experimentation.
Ryan C. Gordon <icculus@icculus.org>
parents:
269
diff
changeset
|
150 |
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
|
151 |
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
|
152 |
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
|
153 |
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
|
154 |
|
269 | 155 |
#undef getval |
156 |
||
157 |
SDL_Quit(); |
|
158 |
printf("\n"); |
|
159 |
||
160 |
return 0; |
|
161 |
} |
|
162 |
||
163 |