Go to the documentation of this file.
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);
114 ctx.glVertex3fv(cube[0]);
116 ctx.glVertex3fv(cube[1]);
118 ctx.glVertex3fv(cube[2]);
120 ctx.glVertex3fv(cube[3]);
123 ctx.glVertex3fv(cube[3]);
125 ctx.glVertex3fv(cube[4]);
127 ctx.glVertex3fv(cube[7]);
129 ctx.glVertex3fv(cube[2]);
132 ctx.glVertex3fv(cube[0]);
134 ctx.glVertex3fv(cube[5]);
136 ctx.glVertex3fv(cube[6]);
138 ctx.glVertex3fv(cube[1]);
141 ctx.glVertex3fv(cube[5]);
143 ctx.glVertex3fv(cube[4]);
145 ctx.glVertex3fv(cube[7]);
147 ctx.glVertex3fv(cube[6]);
150 ctx.glVertex3fv(cube[5]);
152 ctx.glVertex3fv(cube[0]);
154 ctx.glVertex3fv(cube[3]);
156 ctx.glVertex3fv(cube[4]);
159 ctx.glVertex3fv(cube[6]);
161 ctx.glVertex3fv(cube[1]);
163 ctx.glVertex3fv(cube[2]);
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[])
221 int swap_interval = 0;
235 for (
i = 1;
i < argc;) {
241 fsaa = atoi(argv[
i+1]);
244 accel = atoi(argv[
i+1]);
251 static const char *options[] = {
"[--fsaa n]",
"[--accel n]",
NULL };
260 state->gl_red_size = 5;
261 state->gl_green_size = 5;
262 state->gl_blue_size = 5;
263 state->gl_depth_size = 16;
264 state->gl_double_buffer = 1;
266 state->gl_multisamplebuffers = 1;
267 state->gl_multisamplesamples = fsaa;
270 state->gl_accelerated = accel;
285 if (LoadContext(&
ctx) < 0) {
286 SDL_Log(
"Could not load GL functions\n");
308 SDL_Log(
"Window Size : %d,%d\n", dw, dh);
310 SDL_Log(
"Draw Size : %d,%d\n", dw, dh);
320 SDL_Log(
"SDL_GL_RED_SIZE: requested %d, got %d\n", 5,
value);
326 SDL_Log(
"SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5,
value);
332 SDL_Log(
"SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5,
value);
338 SDL_Log(
"SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16,
value);
345 SDL_Log(
"SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n",
value);
352 SDL_Log(
"SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
362 SDL_Log(
"SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
372 ctx.glLoadIdentity();
373 ctx.glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
375 ctx.glLoadIdentity();
402 if (update_swap_interval) {
403 SDL_Log(
"Swap interval to be set to %d\n", swap_interval);
406 for (
i = 0;
i <
state->num_windows; ++
i) {
411 if (update_swap_interval) {
415 ctx.glViewport(0, 0,
w,
h);
424 SDL_Log(
"%2.2f frames per second\n",
425 ((
double)
frames * 1000) / (now - then));
#define SDL_BITSPERPIXEL(X)
@ SDL_LOG_CATEGORY_APPLICATION
@ SDL_GL_ACCELERATED_VISUAL
@ SDL_GL_MULTISAMPLEBUFFERS
#define SDL_GL_CreateContext
#define GL_COLOR_BUFFER_BIT
GLfloat GLfloat GLfloat GLfloat h
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
SDLTest_CommonState * SDLTest_CommonCreateState(char **argv, Uint32 flags)
Parse command line parameters and create common state.
The structure that defines a display mode.
void SDLTest_CommonQuit(SDLTest_CommonState *state)
Close test window.
#define SDL_GetWindowSize
#define SDL_GL_GetDrawableSize
#define GL_DEPTH_BUFFER_BIT
static screen_context_t context
int main(int argc, char *argv[])
@ SDL_RENDERER_PRESENTVSYNC
int SDLTest_CommonArg(SDLTest_CommonState *state, int index)
Process one common argument.
#define SDL_GL_GetSwapInterval
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
void SDLTest_CommonLogUsage(SDLTest_CommonState *state, const char *argv0, const char **options)
Logs command line usage info.
#define SDL_GL_SetSwapInterval
SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
Open test window.
void * SDL_GLContext
An opaque handle to an OpenGL context.
#define SDL_LogSetPriority
GLsizei const GLfloat * value
#define SDL_GL_MakeCurrent
#define SDL_GL_GetAttribute
#define SDL_GetCurrentDisplayMode
#define SDL_GL_SwapWindow
void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done)
Common event handler for test windows.
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_GL_DeleteContext
@ SDL_GL_MULTISAMPLESAMPLES
GLubyte GLubyte GLubyte GLubyte w