comparison src/video/SDL_renderer_gl.c @ 3685:64ce267332c6

Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 21 Jan 2010 06:21:52 +0000
parents 8b4c0320638e
children f7b03b6838cb
comparison
equal deleted inserted replaced
3684:cc564f08884f 3685:64ce267332c6
319 renderer->RenderWritePixels = GL_RenderWritePixels; 319 renderer->RenderWritePixels = GL_RenderWritePixels;
320 renderer->RenderPresent = GL_RenderPresent; 320 renderer->RenderPresent = GL_RenderPresent;
321 renderer->DestroyTexture = GL_DestroyTexture; 321 renderer->DestroyTexture = GL_DestroyTexture;
322 renderer->DestroyRenderer = GL_DestroyRenderer; 322 renderer->DestroyRenderer = GL_DestroyRenderer;
323 renderer->info = GL_RenderDriver.info; 323 renderer->info = GL_RenderDriver.info;
324 renderer->window = window->id; 324 renderer->window = window;
325 renderer->driverdata = data; 325 renderer->driverdata = data;
326 326
327 renderer->info.flags = 327 renderer->info.flags =
328 (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED); 328 (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED);
329 329
330 if (GL_LoadFunctions(data) < 0) { 330 if (GL_LoadFunctions(data) < 0) {
331 GL_DestroyRenderer(renderer); 331 GL_DestroyRenderer(renderer);
332 return NULL; 332 return NULL;
333 } 333 }
334 334
335 data->context = SDL_GL_CreateContext(window->id); 335 data->context = SDL_GL_CreateContext(window);
336 if (!data->context) { 336 if (!data->context) {
337 GL_DestroyRenderer(renderer); 337 GL_DestroyRenderer(renderer);
338 return NULL; 338 return NULL;
339 } 339 }
340 if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { 340 if (SDL_GL_MakeCurrent(window, data->context) < 0) {
341 GL_DestroyRenderer(renderer); 341 GL_DestroyRenderer(renderer);
342 return NULL; 342 return NULL;
343 } 343 }
344 #ifdef __MACOSX__ 344 #ifdef __MACOSX__
345 /* Enable multi-threaded rendering */ 345 /* Enable multi-threaded rendering */
440 440
441 static int 441 static int
442 GL_ActivateRenderer(SDL_Renderer * renderer) 442 GL_ActivateRenderer(SDL_Renderer * renderer)
443 { 443 {
444 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; 444 GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
445 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 445 SDL_Window *window = renderer->window;
446 446
447 if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { 447 if (SDL_GL_MakeCurrent(window, data->context) < 0) {
448 return -1; 448 return -1;
449 } 449 }
450 if (data->updateSize) { 450 if (data->updateSize) {
451 data->glMatrixMode(GL_PROJECTION); 451 data->glMatrixMode(GL_PROJECTION);
452 data->glLoadIdentity(); 452 data->glLoadIdentity();
750 750
751 static int 751 static int
752 GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) 752 GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
753 { 753 {
754 GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; 754 GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
755 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 755 SDL_Window *window = renderer->window;
756 GL_TextureData *data; 756 GL_TextureData *data;
757 GLint internalFormat; 757 GLint internalFormat;
758 GLenum format, type; 758 GLenum format, type;
759 int texture_w, texture_h; 759 int texture_w, texture_h;
760 GLuint shader = 0; 760 GLuint shader = 0;
1405 static int 1405 static int
1406 GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, 1406 GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
1407 Uint32 pixel_format, void * pixels, int pitch) 1407 Uint32 pixel_format, void * pixels, int pitch)
1408 { 1408 {
1409 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; 1409 GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
1410 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 1410 SDL_Window *window = renderer->window;
1411 GLint internalFormat; 1411 GLint internalFormat;
1412 GLenum format, type; 1412 GLenum format, type;
1413 Uint8 *src, *dst, *tmp; 1413 Uint8 *src, *dst, *tmp;
1414 int length, rows; 1414 int length, rows;
1415 1415
1452 static int 1452 static int
1453 GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, 1453 GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
1454 Uint32 pixel_format, const void * pixels, int pitch) 1454 Uint32 pixel_format, const void * pixels, int pitch)
1455 { 1455 {
1456 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; 1456 GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
1457 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 1457 SDL_Window *window = renderer->window;
1458 GLint internalFormat; 1458 GLint internalFormat;
1459 GLenum format, type; 1459 GLenum format, type;
1460 Uint8 *src, *dst, *tmp; 1460 Uint8 *src, *dst, *tmp;
1461 int length, rows; 1461 int length, rows;
1462 1462