Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gl.c @ 2839:f89700cc9272
Progress, maybe. :)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 06 Dec 2008 17:41:01 +0000 |
parents | b128b94ed31e |
children | 53ca0d758b0a |
comparison
equal
deleted
inserted
replaced
2838:00356f22195a | 2839:f89700cc9272 |
---|---|
43 | 43 |
44 /* !!! FIXME: this should go in a higher level than the GL renderer. */ | 44 /* !!! FIXME: this should go in a higher level than the GL renderer. */ |
45 static __inline__ int | 45 static __inline__ int |
46 bytes_per_pixel(const Uint32 format) | 46 bytes_per_pixel(const Uint32 format) |
47 { | 47 { |
48 if (!SDL_ISPIXELFORMAT_FOURCC(format)) { | |
49 return SDL_BYTESPERPIXEL(format); | |
50 } | |
51 | |
52 /* FOURCC format */ | |
48 switch (format) { | 53 switch (format) { |
54 case SDL_PIXELFORMAT_YV12: | |
55 case SDL_PIXELFORMAT_IYUV: | |
56 case SDL_PIXELFORMAT_YUY2: | |
49 case SDL_PIXELFORMAT_UYVY: | 57 case SDL_PIXELFORMAT_UYVY: |
50 /* !!! FIXME: other YUV formats here... */ | 58 case SDL_PIXELFORMAT_YVYU: |
51 return 2; | 59 return 2; |
52 default: | 60 default: |
53 return SDL_BYTESPERPIXEL(format); | 61 return 1; /* shouldn't ever hit this. */ |
54 } | 62 } |
55 return -1; /* shouldn't ever hit this. */ | |
56 } | 63 } |
57 | 64 |
58 | 65 |
59 static const float inv255f = 1.0f / 255.0f; | 66 static const float inv255f = 1.0f / 255.0f; |
60 | 67 |
721 texture_h = power_of_2(texture->h); | 728 texture_h = power_of_2(texture->h); |
722 data->texw = (GLfloat) (texture->w) / texture_w; | 729 data->texw = (GLfloat) (texture->w) / texture_w; |
723 data->texh = (GLfloat) texture->h / texture_h; | 730 data->texh = (GLfloat) texture->h / texture_h; |
724 } | 731 } |
725 | 732 |
733 /* YUV formats use RGBA but are really two bytes per pixel */ | |
734 if (internalFormat == GL_RGBA && bytes_per_pixel(texture->format) < 4) { | |
735 texture_w = (texture_w * bytes_per_pixel(texture->format)) / 4; | |
736 } | |
737 | |
726 data->format = format; | 738 data->format = format; |
727 data->formattype = type; | 739 data->formattype = type; |
728 renderdata->glBindTexture(data->type, data->texture); | 740 renderdata->glBindTexture(data->type, data->texture); |
729 renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, | 741 renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, |
730 GL_NEAREST); | 742 GL_NEAREST); |