Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gl.c @ 2832:0379769e8caa
The matrices have already been set, so you don't have to re-set them.
You always need to reset the viewport when activating the renderer in
case the context had been set to a different window previously.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 05 Dec 2008 06:22:19 +0000 |
parents | 49243a6e9ff1 |
children | c2e182a37f5f |
comparison
equal
deleted
inserted
replaced
2831:7173fc5c7ef6 | 2832:0379769e8caa |
---|---|
119 }; | 119 }; |
120 | 120 |
121 typedef struct | 121 typedef struct |
122 { | 122 { |
123 SDL_GLContext context; | 123 SDL_GLContext context; |
124 SDL_bool updateSize; | |
125 SDL_bool GL_ARB_texture_rectangle_supported; | 124 SDL_bool GL_ARB_texture_rectangle_supported; |
126 SDL_bool GL_EXT_paletted_texture_supported; | 125 SDL_bool GL_EXT_paletted_texture_supported; |
127 int blendMode; | 126 int blendMode; |
128 int scaleMode; | 127 int scaleMode; |
129 | 128 |
356 if (data->GL_ARB_texture_rectangle_supported) { | 355 if (data->GL_ARB_texture_rectangle_supported) { |
357 data->glEnable(GL_TEXTURE_RECTANGLE_ARB); | 356 data->glEnable(GL_TEXTURE_RECTANGLE_ARB); |
358 } else { | 357 } else { |
359 data->glEnable(GL_TEXTURE_2D); | 358 data->glEnable(GL_TEXTURE_2D); |
360 } | 359 } |
361 data->updateSize = SDL_TRUE; | 360 data->glMatrixMode(GL_PROJECTION); |
361 data->glLoadIdentity(); | |
362 data->glMatrixMode(GL_MODELVIEW); | |
363 data->glLoadIdentity(); | |
362 | 364 |
363 return renderer; | 365 return renderer; |
364 } | 366 } |
365 | 367 |
366 static int | 368 static int |
370 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | 372 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
371 | 373 |
372 if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { | 374 if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { |
373 return -1; | 375 return -1; |
374 } | 376 } |
375 if (data->updateSize) { | 377 data->glViewport(0, 0, window->w, window->h); |
376 data->glMatrixMode(GL_PROJECTION); | 378 data->glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, 0.0, |
377 data->glLoadIdentity(); | 379 1.0); |
378 data->glMatrixMode(GL_MODELVIEW); | |
379 data->glLoadIdentity(); | |
380 data->glViewport(0, 0, window->w, window->h); | |
381 data->glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, | |
382 0.0, 1.0); | |
383 data->updateSize = SDL_FALSE; | |
384 } | |
385 return 0; | 380 return 0; |
386 } | 381 } |
387 | 382 |
388 static int | 383 static int |
389 GL_DisplayModeChanged(SDL_Renderer * renderer) | 384 GL_DisplayModeChanged(SDL_Renderer * renderer) |
390 { | 385 { |
391 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 386 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
392 | 387 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
393 data->updateSize = SDL_TRUE; | 388 |
394 return 0; | 389 data->glViewport(0, 0, window->w, window->h); |
390 data->glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, 0.0, | |
391 1.0); | |
395 } | 392 } |
396 | 393 |
397 static __inline__ int | 394 static __inline__ int |
398 power_of_2(int input) | 395 power_of_2(int input) |
399 { | 396 { |