Mercurial > sdl-ios-xcode
comparison test/testgles.c @ 3408:55541ddf13e3
Support for GL initialization parameters has been added.
author | Mike Gorchak <lestat@i.com.ua> |
---|---|
date | Wed, 21 Oct 2009 14:51:42 +0000 |
parents | 5ecc05616f39 |
children | c92950635837 |
comparison
equal
deleted
inserted
replaced
3407:d3baf5ac4e37 | 3408:55541ddf13e3 |
---|---|
13 | 13 |
14 #include "SDL_opengles.h" | 14 #include "SDL_opengles.h" |
15 | 15 |
16 static CommonState *state; | 16 static CommonState *state; |
17 static SDL_GLContext *context = NULL; | 17 static SDL_GLContext *context = NULL; |
18 static int depth = 16; | |
18 | 19 |
19 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ | 20 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ |
20 static void | 21 static void |
21 quit(int rc) | 22 quit(int rc) |
22 { | 23 { |
116 ++fsaa; | 117 ++fsaa; |
117 consumed = 1; | 118 consumed = 1; |
118 } else if (SDL_strcasecmp(argv[i], "--accel") == 0) { | 119 } else if (SDL_strcasecmp(argv[i], "--accel") == 0) { |
119 ++accel; | 120 ++accel; |
120 consumed = 1; | 121 consumed = 1; |
122 } else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) { | |
123 i++; | |
124 if (!argv[i]) { | |
125 consumed = -1; | |
126 } else { | |
127 depth = SDL_atoi(argv[i]); | |
128 consumed = 1; | |
129 } | |
121 } else { | 130 } else { |
122 consumed = -1; | 131 consumed = -1; |
123 } | 132 } |
124 } | 133 } |
125 if (consumed < 0) { | 134 if (consumed < 0) { |
126 fprintf(stderr, "Usage: %s %s [--fsaa] [--accel]\n", argv[0], | 135 fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], |
127 CommonUsage(state)); | 136 CommonUsage(state)); |
128 quit(1); | 137 quit(1); |
129 } | 138 } |
130 i += consumed; | 139 i += consumed; |
131 } | 140 } |
132 | 141 |
133 /* Set OpenGL parameters */ | 142 /* Set OpenGL parameters */ |
134 state->window_flags |= SDL_WINDOW_OPENGL; | 143 state->window_flags |= SDL_WINDOW_OPENGL; |
135 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); | 144 state->gl_red_size = 5; |
136 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); | 145 state->gl_green_size = 5; |
137 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); | 146 state->gl_blue_size = 5; |
138 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); | 147 state->gl_depth_size = depth; |
139 if (fsaa) { | 148 if (fsaa) { |
140 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); | 149 state->gl_multisamplebuffers=1; |
141 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa); | 150 state->gl_multisamplesamples=fsaa; |
142 } | 151 } |
143 if (accel) { | 152 if (accel) { |
144 SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); | 153 state->gl_accelerated=1; |
145 } | 154 } |
146 if (!CommonInit(state)) { | 155 if (!CommonInit(state)) { |
147 quit(2); | 156 quit(2); |
148 } | 157 } |
149 | 158 |
167 } else { | 176 } else { |
168 SDL_GL_SetSwapInterval(0); | 177 SDL_GL_SetSwapInterval(0); |
169 } | 178 } |
170 | 179 |
171 SDL_GetCurrentDisplayMode(&mode); | 180 SDL_GetCurrentDisplayMode(&mode); |
172 printf("Screen BPP: %d\n", SDL_BITSPERPIXEL(mode.format)); | 181 printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); |
173 printf("\n"); | 182 printf("\n"); |
174 printf("Vendor : %s\n", glGetString(GL_VENDOR)); | 183 printf("Vendor : %s\n", glGetString(GL_VENDOR)); |
175 printf("Renderer : %s\n", glGetString(GL_RENDERER)); | 184 printf("Renderer : %s\n", glGetString(GL_RENDERER)); |
176 printf("Version : %s\n", glGetString(GL_VERSION)); | 185 printf("Version : %s\n", glGetString(GL_VERSION)); |
177 printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); | 186 printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); |
198 fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", | 207 fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", |
199 SDL_GetError()); | 208 SDL_GetError()); |
200 } | 209 } |
201 status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); | 210 status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); |
202 if (!status) { | 211 if (!status) { |
203 printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); | 212 printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); |
204 } else { | 213 } else { |
205 fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", | 214 fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", |
206 SDL_GetError()); | 215 SDL_GetError()); |
207 } | 216 } |
208 if (fsaa) { | 217 if (fsaa) { |