Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gl.c @ 2836:b128b94ed31e
Rebind the context to the window area and update matrices when the window size changes
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 06 Dec 2008 05:23:35 +0000 |
parents | f38257b5d936 |
children | f89700cc9272 |
comparison
equal
deleted
inserted
replaced
2835:f38257b5d936 | 2836:b128b94ed31e |
---|---|
421 | 421 |
422 if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { | 422 if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { |
423 return -1; | 423 return -1; |
424 } | 424 } |
425 if (data->updateSize) { | 425 if (data->updateSize) { |
426 GL_DisplayModeChanged(renderer); | 426 data->glMatrixMode(GL_PROJECTION); |
427 data->glLoadIdentity(); | |
428 data->glMatrixMode(GL_MODELVIEW); | |
429 data->glLoadIdentity(); | |
430 data->glViewport(0, 0, window->w, window->h); | |
431 data->glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, | |
432 0.0, 1.0); | |
427 data->updateSize = SDL_FALSE; | 433 data->updateSize = SDL_FALSE; |
428 } | 434 } |
429 return 0; | 435 return 0; |
430 } | 436 } |
431 | 437 |
432 static int | 438 static int |
433 GL_DisplayModeChanged(SDL_Renderer * renderer) | 439 GL_DisplayModeChanged(SDL_Renderer * renderer) |
434 { | 440 { |
435 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 441 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
436 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | 442 |
437 | 443 /* Rebind the context to the window area and update matrices */ |
438 data->glMatrixMode(GL_PROJECTION); | 444 data->updateSize = SDL_TRUE; |
439 data->glLoadIdentity(); | 445 return GL_ActivateRenderer(renderer); |
440 data->glMatrixMode(GL_MODELVIEW); | |
441 data->glLoadIdentity(); | |
442 data->glViewport(0, 0, window->w, window->h); | |
443 data->glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, 0.0, | |
444 1.0); | |
445 return 0; | |
446 } | 446 } |
447 | 447 |
448 static __inline__ int | 448 static __inline__ int |
449 power_of_2(int input) | 449 power_of_2(int input) |
450 { | 450 { |