diff options
author | Sam Lantinga <slouken@libsdl.org> | 2008-12-06 17:41:01 +0000 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2008-12-06 17:41:01 +0000 |
commit | 4bad3c66c180d48fa5cb7634e6b426582f8ccab6 (patch) | |
tree | a10b58753e42a3da23c452eed0aa97014e9a21b9 | |
parent | b89eada0b9129349e7c32e4d1911c65156ac3c40 (diff) |
Progress, maybe. :)
-rw-r--r-- | src/video/SDL_renderer_gl.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/video/SDL_renderer_gl.c b/src/video/SDL_renderer_gl.c index 0c7f5119c5..37510fe33b 100644 --- a/src/video/SDL_renderer_gl.c +++ b/src/video/SDL_renderer_gl.c @@ -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. */ } @@ -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); |