comparison src/video/SDL_renderer_gl.c @ 2233:fb01ee9716bc

Test using glTextureRangeAPPLE This actually ends up being quite a bit slower on my MacBook, but I'm checking it in to test on a PPC iMac. Maybe someone knows why it's slower?
author Sam Lantinga <slouken@libsdl.org>
date Sun, 12 Aug 2007 16:53:58 +0000
parents 9b7d29d2432b
children 741afd8402cf
comparison
equal deleted inserted replaced
2232:6630fefab312 2233:fb01ee9716bc
115 115
116 typedef struct 116 typedef struct
117 { 117 {
118 SDL_GLContext context; 118 SDL_GLContext context;
119 SDL_bool updateSize; 119 SDL_bool updateSize;
120 SDL_bool GL_ARB_texture_rectangle_supported;
120 SDL_bool GL_EXT_paletted_texture_supported; 121 SDL_bool GL_EXT_paletted_texture_supported;
121 SDL_bool GL_ARB_texture_rectangle_supported;
122 int blendMode; 122 int blendMode;
123 int scaleMode; 123 int scaleMode;
124 124
125 /* OpenGL functions */ 125 /* OpenGL functions */
126 #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; 126 #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
127 #include "SDL_glfuncs.h" 127 #include "SDL_glfuncs.h"
128 #undef SDL_PROC 128 #undef SDL_PROC
129 129
130 PFNGLCOLORTABLEEXTPROC glColorTableEXT; 130 PFNGLCOLORTABLEEXTPROC glColorTableEXT;
131 void (*glTextureRangeAPPLE) (GLenum target, GLsizei length,
132 const GLvoid * pointer);
131 } GL_RenderData; 133 } GL_RenderData;
132 134
133 typedef struct 135 typedef struct
134 { 136 {
135 GLuint texture; 137 GLuint texture;
327 info->texture_formats[j++] = info->texture_formats[i]; 329 info->texture_formats[j++] = info->texture_formats[i];
328 } 330 }
329 } 331 }
330 --info->num_texture_formats; 332 --info->num_texture_formats;
331 } 333 }
334 if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) {
335 data->glTextureRangeAPPLE =
336 (void (*)(GLenum, GLsizei, const GLvoid *))
337 SDL_GL_GetProcAddress("glTextureRangeAPPLE");
338 }
332 339
333 /* Set up parameters for rendering */ 340 /* Set up parameters for rendering */
334 data->blendMode = -1; 341 data->blendMode = -1;
335 data->scaleMode = -1; 342 data->scaleMode = -1;
336 data->glDisable(GL_DEPTH_TEST); 343 data->glDisable(GL_DEPTH_TEST);
448 internalFormat = GL_RGB8; 455 internalFormat = GL_RGB8;
449 format = GL_RGB; 456 format = GL_RGB;
450 type = GL_UNSIGNED_BYTE; 457 type = GL_UNSIGNED_BYTE;
451 break; 458 break;
452 case SDL_PIXELFORMAT_RGB888: 459 case SDL_PIXELFORMAT_RGB888:
460 #ifdef __MACOSX__
461 internalFormat = GL_RGBA;
462 format = GL_BGRA;
463 type = GL_UNSIGNED_INT_8_8_8_8_REV;
464 #else
453 internalFormat = GL_RGB8; 465 internalFormat = GL_RGB8;
454 format = GL_BGRA; 466 format = GL_BGRA;
455 type = GL_UNSIGNED_BYTE; 467 type = GL_UNSIGNED_BYTE;
468 #endif
456 break; 469 break;
457 case SDL_PIXELFORMAT_BGR24: 470 case SDL_PIXELFORMAT_BGR24:
458 internalFormat = GL_RGB8; 471 internalFormat = GL_RGB8;
459 format = GL_BGR; 472 format = GL_BGR;
460 type = GL_UNSIGNED_BYTE; 473 type = GL_UNSIGNED_BYTE;
561 renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE, 574 renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
562 GL_STORAGE_CACHED_APPLE); 575 GL_STORAGE_CACHED_APPLE);
563 } 576 }
564 if (data->pixels && internalFormat == GL_RGBA && format == GL_BGRA 577 if (data->pixels && internalFormat == GL_RGBA && format == GL_BGRA
565 && type == GL_UNSIGNED_INT_8_8_8_8_REV && data->pixels) { 578 && type == GL_UNSIGNED_INT_8_8_8_8_REV && data->pixels) {
579 if (renderdata->glTextureRangeAPPLE) {
580 renderdata->glTextureRangeAPPLE(data->type,
581 texture->h * data->pitch,
582 data->pixels);
583 }
566 renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); 584 renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
567 renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, 585 renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
568 texture_h, 0, format, type, data->pixels); 586 texture_h, 0, format, type, data->pixels);
569 } else 587 } else
570 #endif 588 #endif
786 SDL_DirtyRect *dirty; 804 SDL_DirtyRect *dirty;
787 void *pixels; 805 void *pixels;
788 int bpp = SDL_BYTESPERPIXEL(texture->format); 806 int bpp = SDL_BYTESPERPIXEL(texture->format);
789 int pitch = texturedata->pitch; 807 int pitch = texturedata->pitch;
790 808
809 #ifdef __MACOSX__
810 if (texture->format == SDL_PIXELFORMAT_RGB888) {
811 int i;
812 Uint8 *p = (Uint8 *) texturedata->pixels;
813 p += 3;
814 for (i = texture->h * pitch / 4; i--;) {
815 *p = 0xff;
816 p += 4;
817 }
818 }
819 #endif
791 SetupTextureUpdate(data, texture, pitch); 820 SetupTextureUpdate(data, texture, pitch);
792 data->glBindTexture(texturedata->type, texturedata->texture); 821 data->glBindTexture(texturedata->type, texturedata->texture);
793 for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) { 822 for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
794 SDL_Rect *rect = &dirty->rect; 823 SDL_Rect *rect = &dirty->rect;
795 pixels = 824 pixels =