comparison src/video/SDL_renderer_gl.c @ 2843:e919f2e3700d

Fixed the shader fragment problems using 2 byte YUV data in a 4 byte RGB texture. This is a total hack though. Maybe we should be using a different texture format?
author Sam Lantinga <slouken@libsdl.org>
date Sat, 06 Dec 2008 18:22:28 +0000
parents 53ca0d758b0a
children 70b63882d2ef
comparison
equal deleted inserted replaced
2842:97ba0be8b565 2843:e919f2e3700d
182 GLenum formattype; 182 GLenum formattype;
183 Uint8 *palette; 183 Uint8 *palette;
184 void *pixels; 184 void *pixels;
185 int pitch; 185 int pitch;
186 SDL_DirtyRectList dirty; 186 SDL_DirtyRectList dirty;
187 int HACK_RYAN_FIXME;
187 } GL_TextureData; 188 } GL_TextureData;
188 189
189 190
190 static void 191 static void
191 GL_SetError(const char *prefix, GLenum result) 192 GL_SetError(const char *prefix, GLenum result)
730 data->texh = (GLfloat) texture->h / texture_h; 731 data->texh = (GLfloat) texture->h / texture_h;
731 } 732 }
732 733
733 /* YUV formats use RGBA but are really two bytes per pixel */ 734 /* YUV formats use RGBA but are really two bytes per pixel */
734 if (internalFormat == GL_RGBA && bytes_per_pixel(texture->format) < 4) { 735 if (internalFormat == GL_RGBA && bytes_per_pixel(texture->format) < 4) {
735 texture_w = (texture_w * bytes_per_pixel(texture->format)) / 4; 736 data->HACK_RYAN_FIXME = 2;
736 } 737 } else {
738 data->HACK_RYAN_FIXME = 1;
739 }
740 texture_w /= data->HACK_RYAN_FIXME;
737 741
738 data->format = format; 742 data->format = format;
739 data->formattype = type; 743 data->formattype = type;
740 renderdata->glBindTexture(data->type, data->texture); 744 renderdata->glBindTexture(data->type, data->texture);
741 renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, 745 renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
861 } else if (texture->format == SDL_PIXELFORMAT_INDEX1MSB) { 865 } else if (texture->format == SDL_PIXELFORMAT_INDEX1MSB) {
862 renderdata->glPixelStorei(GL_UNPACK_LSB_FIRST, 0); 866 renderdata->glPixelStorei(GL_UNPACK_LSB_FIRST, 0);
863 } 867 }
864 renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 868 renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
865 renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, 869 renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH,
866 pitch / bytes_per_pixel(texture->format)); 870 (pitch / bytes_per_pixel(texture->format) / ((GL_TextureData *)texture->driverdata)->HACK_RYAN_FIXME));
867 } 871 }
868 872
869 static int 873 static int
870 GL_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) 874 GL_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
871 { 875 {
1009 pixels = 1013 pixels =
1010 (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch + 1014 (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch +
1011 rect->x * bpp); 1015 rect->x * bpp);
1012 printf("texsubimage2d(%d,%d,%d,%d)\n", (int) rect->x, (int) rect->y, (int) rect->w, (int) rect->h); 1016 printf("texsubimage2d(%d,%d,%d,%d)\n", (int) rect->x, (int) rect->y, (int) rect->w, (int) rect->h);
1013 data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y, 1017 data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
1014 rect->w, rect->h, texturedata->format, 1018 rect->w / texturedata->HACK_RYAN_FIXME, rect->h, texturedata->format,
1015 texturedata->formattype, pixels); 1019 texturedata->formattype, pixels);
1016 } 1020 }
1017 SDL_ClearDirtyRects(&texturedata->dirty); 1021 SDL_ClearDirtyRects(&texturedata->dirty);
1018 } 1022 }
1019 1023