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

Commit

Permalink
Progress, maybe. :)
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 6, 2008
1 parent 7031994 commit 472011e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/video/SDL_renderer_gl.c
Expand Up @@ -45,14 +45,21 @@
static __inline__ int
bytes_per_pixel(const Uint32 format)
{
if (!SDL_ISPIXELFORMAT_FOURCC(format)) {
return SDL_BYTESPERPIXEL(format);
}

/* FOURCC format */
switch (format) {
case SDL_PIXELFORMAT_YV12:
case SDL_PIXELFORMAT_IYUV:
case SDL_PIXELFORMAT_YUY2:
case SDL_PIXELFORMAT_UYVY:
/* !!! FIXME: other YUV formats here... */
case SDL_PIXELFORMAT_YVYU:
return 2;
default:
return SDL_BYTESPERPIXEL(format);
return 1; /* shouldn't ever hit this. */
}
return -1; /* shouldn't ever hit this. */
}


Expand Down Expand Up @@ -723,6 +730,11 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
data->texh = (GLfloat) texture->h / texture_h;
}

/* YUV formats use RGBA but are really two bytes per pixel */
if (internalFormat == GL_RGBA && bytes_per_pixel(texture->format) < 4) {
texture_w = (texture_w * bytes_per_pixel(texture->format)) / 4;
}

data->format = format;
data->formattype = type;
renderdata->glBindTexture(data->type, data->texture);
Expand Down

0 comments on commit 472011e

Please sign in to comment.