From 53650873113374498daa881919f05f420a2c10e7 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sat, 15 Sep 2012 23:59:52 +0200 Subject: [PATCH] Fix LUT textures in GLES. --- gfx/image.c | 24 ++++++++++++++++++++---- gfx/shader_cg.c | 4 ++-- gfx/shader_glsl.c | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gfx/image.c b/gfx/image.c index 1ec9d9bda8..c956b8beef 100644 --- a/gfx/image.c +++ b/gfx/image.c @@ -61,7 +61,11 @@ bool texture_image_load(const char *path, struct texture_image *out_img) uint32_t g = (src[x] & fmt->Gmask) >> fmt->Gshift; uint32_t b = (src[x] & fmt->Bmask) >> fmt->Bshift; uint32_t a = (src[x] & fmt->Amask) >> fmt->Ashift; - dst[x] = (b << 24) | (g << 16) | (r << 8) | a; +#ifdef HAVE_OPENGLES2 + dst[x] = (a << 24) | (b << 16) | (g << 8) | r; +#else + dst[x] = (a << 24) | (r << 16) | (g << 8) | b; +#endif } } } @@ -82,7 +86,11 @@ bool texture_image_load(const char *path, struct texture_image *out_img) uint32_t r = (color & fmt->Rmask) >> fmt->Rshift; uint32_t g = (color & fmt->Gmask) >> fmt->Gshift; uint32_t b = (color & fmt->Bmask) >> fmt->Bshift; - dst[x] = (b << 24) | (g << 16) | (r << 8) | 0xff; +#ifdef HAVE_OPENGLES2 + dst[x] = (0xff << 24) | (b << 16) | (g << 8) | r; +#else + dst[x] = (0xff << 24) | (r << 16) | (g << 8) | b; +#endif } } } @@ -151,7 +159,11 @@ bool texture_image_load(const char *path, struct texture_image *out_img) uint32_t r = tmp[i * 4 + 2]; uint32_t a = tmp[i * 4 + 3]; - out_img->pixels[i] = (b << 24) | (g << 16) | (r << 8) | a; +#ifdef HAVE_OPENGLES2 + out_img->pixels[i] = (a << 24) | (b << 16) | (g << 8) | r; +#else + out_img->pixels[i] = (a << 24) | (r << 16) | (g << 8) | b; +#endif } } else if (bits == 24) @@ -163,7 +175,11 @@ bool texture_image_load(const char *path, struct texture_image *out_img) uint32_t r = tmp[i * 3 + 2]; uint32_t a = 0xff; - out_img->pixels[i] = (b << 24) | (g << 16) | (r << 8) | a; +#ifdef HAVE_OPENGLES2 + out_img->pixels[i] = (a << 24) | (b << 16) | (g << 8) | r; +#else + out_img->pixels[i] = (a << 24) | (r << 16) | (g << 8) | b; +#endif } } else diff --git a/gfx/shader_cg.c b/gfx/shader_cg.c index c730f3c040..f197226004 100644 --- a/gfx/shader_cg.c +++ b/gfx/shader_cg.c @@ -535,8 +535,8 @@ static void load_texture_data(GLuint *obj, const struct texture_image *img, bool glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glTexImage2D(GL_TEXTURE_2D, - 0, GL_RGBA, img->width, img->height, - 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, img->pixels); + 0, RARCH_GL_INTERNAL_FORMAT, img->width, img->height, + 0, RARCH_GL_TEXTURE_TYPE, RARCH_GL_FORMAT32, img->pixels); #endif free(img->pixels); diff --git a/gfx/shader_glsl.c b/gfx/shader_glsl.c index 9c9bf788ae..9da4e32a9d 100644 --- a/gfx/shader_glsl.c +++ b/gfx/shader_glsl.c @@ -433,7 +433,7 @@ static bool get_texture_image(const char *shader_path, xmlNodePtr ptr) glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glTexImage2D(GL_TEXTURE_2D, 0, RARCH_GL_INTERNAL_FORMAT, - img.width, img.height, 0, RARCH_GL_TEXTURE_TYPE, GL_UNSIGNED_INT, img.pixels); + img.width, img.height, 0, RARCH_GL_TEXTURE_TYPE, RARCH_GL_FORMAT32, img.pixels); pglActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0);