comparison test/testgles.c @ 3194:c18c03927a77

Proper window resize handling in GLES test application.
author Mike Gorchak <lestat@i.com.ua>
date Thu, 11 Jun 2009 06:03:05 +0000
parents 7f684f249ec9
children c64ae6ee6a6d
comparison
equal deleted inserted replaced
3193:64e4442676a6 3194:c18c03927a77
240 240
241 /* Continue for next window */ 241 /* Continue for next window */
242 continue; 242 continue;
243 } 243 }
244 244
245 glViewport(0, 0, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
245 glMatrixMode(GL_PROJECTION); 246 glMatrixMode(GL_PROJECTION);
246 glLoadIdentity(); 247 glLoadIdentity();
247 glOrthof(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); 248 glOrthof(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
248 glMatrixMode(GL_MODELVIEW); 249 glMatrixMode(GL_MODELVIEW);
249 glLoadIdentity(); 250 glLoadIdentity();
258 done = 0; 259 done = 0;
259 while (!done) { 260 while (!done) {
260 /* Check for events */ 261 /* Check for events */
261 ++frames; 262 ++frames;
262 while (SDL_PollEvent(&event)) { 263 while (SDL_PollEvent(&event)) {
264 switch (event.type) {
265 case SDL_WINDOWEVENT:
266 switch (event.window.event) {
267 case SDL_WINDOWEVENT_RESIZED:
268 for (i = 0; i < state->num_windows; ++i) {
269 if (event.window.windowID == state->windows[i]) {
270 status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
271 if (status) {
272 printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
273 break;
274 }
275 /* Change view port to the new window dimensions */
276 glViewport(0, 0, event.window.data1, event.window.data2);
277 /* Update window content */
278 Render();
279 SDL_GL_SwapWindow(state->windows[i]);
280 break;
281 }
282 }
283 break;
284 }
285 }
263 CommonEvent(state, &event, &done); 286 CommonEvent(state, &event, &done);
264 } 287 }
265 for (i = 0; i < state->num_windows; ++i) { 288 for (i = 0; i < state->num_windows; ++i) {
266 int w, h;
267 status = SDL_GL_MakeCurrent(state->windows[i], context[i]); 289 status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
268 if (status) { 290 if (status) {
269 printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); 291 printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
270 292
271 /* Continue for next window */ 293 /* Continue for next window */
272 continue; 294 continue;
273 } 295 }
274 SDL_GetWindowSize(state->windows[i], &w, &h);
275 glViewport(0, 0, w, h);
276 Render(); 296 Render();
277 SDL_GL_SwapWindow(state->windows[i]); 297 SDL_GL_SwapWindow(state->windows[i]);
278 } 298 }
279 } 299 }
280 300