Mercurial > sdl-ios-xcode
comparison test/testgl2.c @ 3571:19691cebb866
Default to allow either accelerated or not
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 15 Dec 2009 20:53:09 +0000 |
parents | 7812d3e9564e |
children | 762e40fb8e28 |
comparison
equal
deleted
inserted
replaced
3570:7812d3e9564e | 3571:19691cebb866 |
---|---|
160 } | 160 } |
161 | 161 |
162 int | 162 int |
163 main(int argc, char *argv[]) | 163 main(int argc, char *argv[]) |
164 { | 164 { |
165 int fsaa, noaccel; | 165 int fsaa, accel; |
166 int value; | 166 int value; |
167 int i, done; | 167 int i, done; |
168 SDL_DisplayMode mode; | 168 SDL_DisplayMode mode; |
169 SDL_Event event; | 169 SDL_Event event; |
170 Uint32 then, now, frames; | 170 Uint32 then, now, frames; |
171 int status; | 171 int status; |
172 | 172 |
173 /* Initialize parameters */ | 173 /* Initialize parameters */ |
174 fsaa = 0; | 174 fsaa = 0; |
175 noaccel = 0; | 175 accel = -1; |
176 | 176 |
177 /* Initialize test framework */ | 177 /* Initialize test framework */ |
178 state = CommonCreateState(argv, SDL_INIT_VIDEO); | 178 state = CommonCreateState(argv, SDL_INIT_VIDEO); |
179 if (!state) { | 179 if (!state) { |
180 return 1; | 180 return 1; |
185 consumed = CommonArg(state, i); | 185 consumed = CommonArg(state, i); |
186 if (consumed == 0) { | 186 if (consumed == 0) { |
187 if (SDL_strcasecmp(argv[i], "--fsaa") == 0) { | 187 if (SDL_strcasecmp(argv[i], "--fsaa") == 0) { |
188 ++fsaa; | 188 ++fsaa; |
189 consumed = 1; | 189 consumed = 1; |
190 } else if (SDL_strcasecmp(argv[i], "--noaccel") == 0) { | 190 } else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i+1 < argc) { |
191 ++noaccel; | 191 accel = atoi(argv[i+1]); |
192 consumed = 1; | 192 consumed = 2; |
193 } else { | 193 } else { |
194 consumed = -1; | 194 consumed = -1; |
195 } | 195 } |
196 } | 196 } |
197 if (consumed < 0) { | 197 if (consumed < 0) { |
198 fprintf(stderr, "Usage: %s %s [--fsaa] [--noaccel]\n", argv[0], | 198 fprintf(stderr, "Usage: %s %s [--fsaa] [--accel n]\n", argv[0], |
199 CommonUsage(state)); | 199 CommonUsage(state)); |
200 quit(1); | 200 quit(1); |
201 } | 201 } |
202 i += consumed; | 202 i += consumed; |
203 } | 203 } |
211 state->gl_double_buffer = 1; | 211 state->gl_double_buffer = 1; |
212 if (fsaa) { | 212 if (fsaa) { |
213 state->gl_multisamplebuffers = 1; | 213 state->gl_multisamplebuffers = 1; |
214 state->gl_multisamplesamples = fsaa; | 214 state->gl_multisamplesamples = fsaa; |
215 } | 215 } |
216 state->gl_accelerated = !noaccel; | 216 if (accel >= 0) { |
217 state->gl_accelerated = accel; | |
218 } | |
217 | 219 |
218 if (!CommonInit(state)) { | 220 if (!CommonInit(state)) { |
219 quit(2); | 221 quit(2); |
220 } | 222 } |
221 | 223 |
280 } else { | 282 } else { |
281 printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", | 283 printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", |
282 SDL_GetError()); | 284 SDL_GetError()); |
283 } | 285 } |
284 } | 286 } |
285 status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); | 287 if (accel >= 0) { |
286 if (!status) { | 288 status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); |
287 printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", !noaccel, | 289 if (!status) { |
288 value); | 290 printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel, |
289 } else { | 291 value); |
290 printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", | 292 } else { |
291 SDL_GetError()); | 293 printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", |
294 SDL_GetError()); | |
295 } | |
292 } | 296 } |
293 | 297 |
294 /* Set rendering settings */ | 298 /* Set rendering settings */ |
295 glMatrixMode(GL_PROJECTION); | 299 glMatrixMode(GL_PROJECTION); |
296 glLoadIdentity(); | 300 glLoadIdentity(); |