Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed bug #1028

pelya      2010-07-21 04:54:41 PDT

GLES_UpdateTexture() ignores pitch value, because of that some textures created
with SDL_CreateTextureFromSurface() are drawn incorrectly, especially if image
width is not multiplier of 2.
  • Loading branch information
slouken committed Jan 20, 2011
1 parent 2d8a58a commit 96a32c928d89d8413a645ae627462a3beaa2bf2b
Showing with 24 additions and 1 deletion.
  1. +24 −1 src/video/SDL_renderer_gles.c
@@ -557,13 +557,36 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
GLenum result;
int bpp = SDL_BYTESPERPIXEL(texture->format);
void * temp_buffer;
void * temp_ptr;
int i;

renderdata->glGetError();
renderdata->glEnable(data->type);
SetupTextureUpdate(renderdata, texture, pitch);

if( rect->w * bpp == pitch ) {
temp_buffer = (void *)pixels; /* No need to reformat */
} else {
/* Reformatting of mem area required */
temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
temp_ptr = temp_buffer;
for (i = 0; i < rect->h; i++) {
SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
temp_ptr += rect->w * bpp;
pixels += pitch;
}
}

renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
rect->h, data->format, data->formattype,
pixels);
temp_buffer);

if( temp_buffer != pixels ) {
SDL_free(temp_buffer);
}

renderdata->glDisable(data->type);
result = renderdata->glGetError();
if (result != GL_NO_ERROR) {

0 comments on commit 96a32c9

Please sign in to comment.