27 typedef struct GL_Context
29 #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; 30 #include "../src/render/opengl/SDL_glfuncs.h" 40 static GL_Context
ctx;
42 static int LoadContext(GL_Context *
data)
44 #if SDL_VIDEO_DRIVER_UIKIT 45 #define __SDL_NOGETPROCADDR__ 46 #elif SDL_VIDEO_DRIVER_ANDROID 47 #define __SDL_NOGETPROCADDR__ 48 #elif SDL_VIDEO_DRIVER_PANDORA 49 #define __SDL_NOGETPROCADDR__ 52 #if defined __SDL_NOGETPROCADDR__ 53 #define SDL_PROC(ret,func,params) data->func=func; 55 #define SDL_PROC(ret,func,params) \ 57 data->func = SDL_GL_GetProcAddress(#func); \ 58 if ( ! data->func ) { \ 59 return SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \ 64 #include "../src/render/opengl/SDL_glfuncs.h" 85 static float color[8][3] = {
95 static float cube[8][3] = {
107 ctx.glClearColor(0.0, 0.0, 0.0, 1.0);
113 ctx.glColor3fv(color[0]);
114 ctx.glVertex3fv(cube[0]);
115 ctx.glColor3fv(color[1]);
116 ctx.glVertex3fv(cube[1]);
117 ctx.glColor3fv(color[2]);
118 ctx.glVertex3fv(cube[2]);
119 ctx.glColor3fv(color[3]);
120 ctx.glVertex3fv(cube[3]);
122 ctx.glColor3fv(color[3]);
123 ctx.glVertex3fv(cube[3]);
124 ctx.glColor3fv(color[4]);
125 ctx.glVertex3fv(cube[4]);
126 ctx.glColor3fv(color[7]);
127 ctx.glVertex3fv(cube[7]);
128 ctx.glColor3fv(color[2]);
129 ctx.glVertex3fv(cube[2]);
131 ctx.glColor3fv(color[0]);
132 ctx.glVertex3fv(cube[0]);
133 ctx.glColor3fv(color[5]);
134 ctx.glVertex3fv(cube[5]);
135 ctx.glColor3fv(color[6]);
136 ctx.glVertex3fv(cube[6]);
137 ctx.glColor3fv(color[1]);
138 ctx.glVertex3fv(cube[1]);
140 ctx.glColor3fv(color[5]);
141 ctx.glVertex3fv(cube[5]);
142 ctx.glColor3fv(color[4]);
143 ctx.glVertex3fv(cube[4]);
144 ctx.glColor3fv(color[7]);
145 ctx.glVertex3fv(cube[7]);
146 ctx.glColor3fv(color[6]);
147 ctx.glVertex3fv(cube[6]);
149 ctx.glColor3fv(color[5]);
150 ctx.glVertex3fv(cube[5]);
151 ctx.glColor3fv(color[0]);
152 ctx.glVertex3fv(cube[0]);
153 ctx.glColor3fv(color[3]);
154 ctx.glVertex3fv(cube[3]);
155 ctx.glColor3fv(color[4]);
156 ctx.glVertex3fv(cube[4]);
158 ctx.glColor3fv(color[6]);
159 ctx.glVertex3fv(cube[6]);
160 ctx.glColor3fv(color[1]);
161 ctx.glVertex3fv(cube[1]);
162 ctx.glColor3fv(color[2]);
163 ctx.glVertex3fv(cube[2]);
164 ctx.glColor3fv(color[7]);
165 ctx.glVertex3fv(cube[7]);
167 ctx.glColor3f(1.0, 0.0, 0.0);
168 ctx.glVertex3fv(cube[0]);
169 ctx.glVertex3fv(cube[1]);
170 ctx.glVertex3fv(cube[2]);
171 ctx.glVertex3fv(cube[3]);
173 ctx.glColor3f(0.0, 1.0, 0.0);
174 ctx.glVertex3fv(cube[3]);
175 ctx.glVertex3fv(cube[4]);
176 ctx.glVertex3fv(cube[7]);
177 ctx.glVertex3fv(cube[2]);
179 ctx.glColor3f(0.0, 0.0, 1.0);
180 ctx.glVertex3fv(cube[0]);
181 ctx.glVertex3fv(cube[5]);
182 ctx.glVertex3fv(cube[6]);
183 ctx.glVertex3fv(cube[1]);
185 ctx.glColor3f(0.0, 1.0, 1.0);
186 ctx.glVertex3fv(cube[5]);
187 ctx.glVertex3fv(cube[4]);
188 ctx.glVertex3fv(cube[7]);
189 ctx.glVertex3fv(cube[6]);
191 ctx.glColor3f(1.0, 1.0, 0.0);
192 ctx.glVertex3fv(cube[5]);
193 ctx.glVertex3fv(cube[0]);
194 ctx.glVertex3fv(cube[3]);
195 ctx.glVertex3fv(cube[4]);
197 ctx.glColor3f(1.0, 0.0, 1.0);
198 ctx.glVertex3fv(cube[6]);
199 ctx.glVertex3fv(cube[1]);
200 ctx.glVertex3fv(cube[2]);
201 ctx.glVertex3fv(cube[7]);
207 ctx.glRotatef(5.0, 1.0, 1.0, 1.0);
211 main(
int argc,
char *argv[])
234 for (i = 1; i < argc;) {
240 fsaa = atoi(argv[i+1]);
242 }
else if (
SDL_strcasecmp(argv[i],
"--accel") == 0 && i+1 < argc) {
243 accel = atoi(argv[i+1]);
250 SDL_Log(
"Usage: %s %s [--fsaa n] [--accel n]\n", argv[0],
284 if (LoadContext(&ctx) < 0) {
285 SDL_Log(
"Could not load GL functions\n");
303 SDL_Log(
"Window Size : %d,%d\n", dw, dh);
305 SDL_Log(
"Draw Size : %d,%d\n", dw, dh);
315 SDL_Log(
"SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
321 SDL_Log(
"SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
327 SDL_Log(
"SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
333 SDL_Log(
"SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
340 SDL_Log(
"SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
347 SDL_Log(
"SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
357 SDL_Log(
"SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
367 ctx.glLoadIdentity();
368 ctx.glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
370 ctx.glLoadIdentity();
391 ctx.glViewport(0, 0, w, h);
400 SDL_Log(
"%2.2f frames per second\n",
401 ((
double) frames * 1000) / (now - then));
#define SDL_GL_CreateContext
SDLTest_CommonState * SDLTest_CommonCreateState(char **argv, Uint32 flags)
Parse command line parameters and create common state.
GLfloat GLfloat GLfloat GLfloat h
int SDLTest_CommonArg(SDLTest_CommonState *state, int index)
Process one common argument.
static screen_context_t context
The structure that defines a display mode.
#define GL_DEPTH_BUFFER_BIT
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
Open test window.
#define SDL_GetWindowSize
#define SDL_GL_GetDrawableSize
void * SDL_GLContext
An opaque handle to an OpenGL context.
#define SDL_GL_GetSwapInterval
void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done)
Common event handler for test windows.
int gl_multisamplebuffers
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
#define SDL_GL_SetSwapInterval
GLubyte GLubyte GLubyte GLubyte w
GLsizei const GLfloat * value
int gl_multisamplesamples
int main(int argc, char *argv[])
const char * SDLTest_CommonUsage(SDLTest_CommonState *state)
Returns common usage information.
#define GL_COLOR_BUFFER_BIT
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_LogSetPriority
#define SDL_GL_MakeCurrent
#define SDL_GL_GetAttribute
#define SDL_GL_DeleteContext
#define SDL_GetCurrentDisplayMode
#define SDL_BITSPERPIXEL(X)
#define SDL_GL_SwapWindow
void SDLTest_CommonQuit(SDLTest_CommonState *state)
Close test window.