Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Test using glTextureRangeAPPLE
Browse files Browse the repository at this point in the history
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?
  • Loading branch information
slouken committed Aug 12, 2007
1 parent 2caaf97 commit e3bb2ab
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/video/SDL_renderer_gl.c
Expand Up @@ -117,8 +117,8 @@ typedef struct
{
SDL_GLContext context;
SDL_bool updateSize;
SDL_bool GL_EXT_paletted_texture_supported;
SDL_bool GL_ARB_texture_rectangle_supported;
SDL_bool GL_EXT_paletted_texture_supported;
int blendMode;
int scaleMode;

Expand All @@ -128,6 +128,8 @@ typedef struct
#undef SDL_PROC

PFNGLCOLORTABLEEXTPROC glColorTableEXT;
void (*glTextureRangeAPPLE) (GLenum target, GLsizei length,
const GLvoid * pointer);
} GL_RenderData;

typedef struct
Expand Down Expand Up @@ -329,6 +331,11 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
}
--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;
Expand Down Expand Up @@ -450,9 +457,15 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
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;
Expand Down Expand Up @@ -563,6 +576,11 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
}
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);
Expand Down Expand Up @@ -788,6 +806,17 @@ GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
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) {
Expand Down

0 comments on commit e3bb2ab

Please sign in to comment.