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

Commit

Permalink
Fixed bug 1315 - Greenish video when video size smaller than texture
Browse files Browse the repository at this point in the history
The incoming pixels are contiguous for the update rectangle.
  • Loading branch information
slouken committed Dec 30, 2011
1 parent d2a1e8e commit 68d7460
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/render/opengl/SDL_render_gl.c
Expand Up @@ -569,15 +569,10 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
rect->h, data->format, data->formattype,
pixels);
if (data->yuv) {
const void *top;

renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, (pitch / 2));

/* Skip to the top of the next texture */
top = (const void*)((const Uint8*)pixels + (texture->h-rect->y) * pitch - rect->x);

/* Skip to the correct offset into the next texture */
pixels = (const void*)((const Uint8*)top + (rect->y / 2) * pitch + rect->x / 2);
pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
if (texture->format == SDL_PIXELFORMAT_YV12) {
renderdata->glBindTexture(data->type, data->vtexture);
} else {
Expand All @@ -587,11 +582,8 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
rect->w/2, rect->h/2,
data->format, data->formattype, pixels);

/* Skip to the top of the next texture */
top = (const void*)((const Uint8*)top + (texture->h * pitch)/4);

/* Skip to the correct offset into the next texture */
pixels = (const void*)((const Uint8*)top + (rect->y / 2) * pitch + rect->x / 2);
pixels = (const void*)((const Uint8*)pixels + (rect->h * pitch)/4);
if (texture->format == SDL_PIXELFORMAT_YV12) {
renderdata->glBindTexture(data->type, data->utexture);
} else {
Expand Down

0 comments on commit 68d7460

Please sign in to comment.