Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gl.c @ 2833:c2e182a37f5f
Whoops, can't call glOrtho() repeatedly
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 05 Dec 2008 07:00:58 +0000 |
parents | 0379769e8caa |
children | f38257b5d936 |
comparison
equal
deleted
inserted
replaced
2832:0379769e8caa | 2833:c2e182a37f5f |
---|---|
119 }; | 119 }; |
120 | 120 |
121 typedef struct | 121 typedef struct |
122 { | 122 { |
123 SDL_GLContext context; | 123 SDL_GLContext context; |
124 SDL_bool updateSize; | |
124 SDL_bool GL_ARB_texture_rectangle_supported; | 125 SDL_bool GL_ARB_texture_rectangle_supported; |
125 SDL_bool GL_EXT_paletted_texture_supported; | 126 SDL_bool GL_EXT_paletted_texture_supported; |
126 int blendMode; | 127 int blendMode; |
127 int scaleMode; | 128 int scaleMode; |
128 | 129 |
355 if (data->GL_ARB_texture_rectangle_supported) { | 356 if (data->GL_ARB_texture_rectangle_supported) { |
356 data->glEnable(GL_TEXTURE_RECTANGLE_ARB); | 357 data->glEnable(GL_TEXTURE_RECTANGLE_ARB); |
357 } else { | 358 } else { |
358 data->glEnable(GL_TEXTURE_2D); | 359 data->glEnable(GL_TEXTURE_2D); |
359 } | 360 } |
361 data->updateSize = SDL_TRUE; | |
362 | |
363 return renderer; | |
364 } | |
365 | |
366 static int | |
367 GL_ActivateRenderer(SDL_Renderer * renderer) | |
368 { | |
369 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | |
370 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | |
371 | |
372 if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { | |
373 return -1; | |
374 } | |
375 if (data->updateSize) { | |
376 GL_DisplayModeChanged(renderer); | |
377 data->updateSize = SDL_FALSE; | |
378 } | |
379 return 0; | |
380 } | |
381 | |
382 static int | |
383 GL_DisplayModeChanged(SDL_Renderer * renderer) | |
384 { | |
385 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | |
386 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | |
387 | |
360 data->glMatrixMode(GL_PROJECTION); | 388 data->glMatrixMode(GL_PROJECTION); |
361 data->glLoadIdentity(); | 389 data->glLoadIdentity(); |
362 data->glMatrixMode(GL_MODELVIEW); | 390 data->glMatrixMode(GL_MODELVIEW); |
363 data->glLoadIdentity(); | 391 data->glLoadIdentity(); |
364 | |
365 return renderer; | |
366 } | |
367 | |
368 static int | |
369 GL_ActivateRenderer(SDL_Renderer * renderer) | |
370 { | |
371 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | |
372 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | |
373 | |
374 if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { | |
375 return -1; | |
376 } | |
377 data->glViewport(0, 0, window->w, window->h); | 392 data->glViewport(0, 0, window->w, window->h); |
378 data->glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, 0.0, | 393 data->glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, 0.0, |
379 1.0); | 394 1.0); |
380 return 0; | 395 return 0; |
381 } | |
382 | |
383 static int | |
384 GL_DisplayModeChanged(SDL_Renderer * renderer) | |
385 { | |
386 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | |
387 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | |
388 | |
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); | |
392 } | 396 } |
393 | 397 |
394 static __inline__ int | 398 static __inline__ int |
395 power_of_2(int input) | 399 power_of_2(int input) |
396 { | 400 { |