Fixed bug 1315 - Greenish video when video size smaller than texture
authorSam Lantinga <slouken@libsdl.org>
Fri, 30 Dec 2011 18:18:42 -0500
changeset 6135b052a5882a47
parent 6128 2804d71badce
child 6136 731cd0659cb5
Fixed bug 1315 - Greenish video when video size smaller than texture

The incoming pixels are contiguous for the update rectangle.
src/render/opengl/SDL_render_gl.c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Fri Dec 30 06:41:41 2011 -0500
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Fri Dec 30 18:18:42 2011 -0500
     1.3 @@ -569,15 +569,10 @@
     1.4                                  rect->h, data->format, data->formattype,
     1.5                                  pixels);
     1.6      if (data->yuv) {
     1.7 -        const void *top;
     1.8 -
     1.9          renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, (pitch / 2));
    1.10  
    1.11 -        /* Skip to the top of the next texture */
    1.12 -        top = (const void*)((const Uint8*)pixels + (texture->h-rect->y) * pitch - rect->x);
    1.13 -
    1.14          /* Skip to the correct offset into the next texture */
    1.15 -        pixels = (const void*)((const Uint8*)top + (rect->y / 2) * pitch + rect->x / 2);
    1.16 +        pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
    1.17          if (texture->format == SDL_PIXELFORMAT_YV12) {
    1.18              renderdata->glBindTexture(data->type, data->vtexture);
    1.19          } else {
    1.20 @@ -587,11 +582,8 @@
    1.21                                      rect->w/2, rect->h/2,
    1.22                                      data->format, data->formattype, pixels);
    1.23  
    1.24 -        /* Skip to the top of the next texture */
    1.25 -        top = (const void*)((const Uint8*)top + (texture->h * pitch)/4);
    1.26 -
    1.27          /* Skip to the correct offset into the next texture */
    1.28 -        pixels = (const void*)((const Uint8*)top + (rect->y / 2) * pitch + rect->x / 2);
    1.29 +        pixels = (const void*)((const Uint8*)pixels + (rect->h * pitch)/4);
    1.30          if (texture->format == SDL_PIXELFORMAT_YV12) {
    1.31              renderdata->glBindTexture(data->type, data->utexture);
    1.32          } else {