Mercurial > sdl-ios-xcode
diff 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 |
line wrap: on
line diff
--- a/src/video/SDL_renderer_gl.c Sun Aug 12 16:26:10 2007 +0000 +++ b/src/video/SDL_renderer_gl.c Sun Aug 12 16:53:58 2007 +0000 @@ -117,8 +117,8 @@ { SDL_GLContext context; SDL_bool updateSize; + SDL_bool GL_ARB_texture_rectangle_supported; SDL_bool GL_EXT_paletted_texture_supported; - SDL_bool GL_ARB_texture_rectangle_supported; int blendMode; int scaleMode; @@ -128,6 +128,8 @@ #undef SDL_PROC PFNGLCOLORTABLEEXTPROC glColorTableEXT; + void (*glTextureRangeAPPLE) (GLenum target, GLsizei length, + const GLvoid * pointer); } GL_RenderData; typedef struct @@ -329,6 +331,11 @@ } --info->num_texture_formats; } + if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) { + data->glTextureRangeAPPLE = + (void (*)(GLenum, GLsizei, const GLvoid *)) + SDL_GL_GetProcAddress("glTextureRangeAPPLE"); + } /* Set up parameters for rendering */ data->blendMode = -1; @@ -450,9 +457,15 @@ type = GL_UNSIGNED_BYTE; break; case SDL_PIXELFORMAT_RGB888: +#ifdef __MACOSX__ + internalFormat = GL_RGBA; + format = GL_BGRA; + type = GL_UNSIGNED_INT_8_8_8_8_REV; +#else internalFormat = GL_RGB8; format = GL_BGRA; type = GL_UNSIGNED_BYTE; +#endif break; case SDL_PIXELFORMAT_BGR24: internalFormat = GL_RGB8; @@ -563,6 +576,11 @@ } if (data->pixels && internalFormat == GL_RGBA && format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV && data->pixels) { + if (renderdata->glTextureRangeAPPLE) { + renderdata->glTextureRangeAPPLE(data->type, + texture->h * data->pitch, + data->pixels); + } renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, texture_h, 0, format, type, data->pixels); @@ -788,6 +806,17 @@ int bpp = SDL_BYTESPERPIXEL(texture->format); int pitch = texturedata->pitch; +#ifdef __MACOSX__ + if (texture->format == SDL_PIXELFORMAT_RGB888) { + int i; + Uint8 *p = (Uint8 *) texturedata->pixels; + p += 3; + for (i = texture->h * pitch / 4; i--;) { + *p = 0xff; + p += 4; + } + } +#endif SetupTextureUpdate(data, texture, pitch); data->glBindTexture(texturedata->type, texturedata->texture); for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {