Fix LUT textures in GLES.

This commit is contained in:
Themaister 2012-09-15 23:59:52 +02:00
parent 759a4c811d
commit 5365087311
3 changed files with 23 additions and 7 deletions

View File

@ -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 g = (src[x] & fmt->Gmask) >> fmt->Gshift;
uint32_t b = (src[x] & fmt->Bmask) >> fmt->Bshift; uint32_t b = (src[x] & fmt->Bmask) >> fmt->Bshift;
uint32_t a = (src[x] & fmt->Amask) >> fmt->Ashift; 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 r = (color & fmt->Rmask) >> fmt->Rshift;
uint32_t g = (color & fmt->Gmask) >> fmt->Gshift; uint32_t g = (color & fmt->Gmask) >> fmt->Gshift;
uint32_t b = (color & fmt->Bmask) >> fmt->Bshift; 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 r = tmp[i * 4 + 2];
uint32_t a = tmp[i * 4 + 3]; 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) 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 r = tmp[i * 3 + 2];
uint32_t a = 0xff; 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 else

View File

@ -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_ALIGNMENT, 4);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexImage2D(GL_TEXTURE_2D, glTexImage2D(GL_TEXTURE_2D,
0, GL_RGBA, img->width, img->height, 0, RARCH_GL_INTERNAL_FORMAT, img->width, img->height,
0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, img->pixels); 0, RARCH_GL_TEXTURE_TYPE, RARCH_GL_FORMAT32, img->pixels);
#endif #endif
free(img->pixels); free(img->pixels);

View File

@ -433,7 +433,7 @@ static bool get_texture_image(const char *shader_path, xmlNodePtr ptr)
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glTexImage2D(GL_TEXTURE_2D, glTexImage2D(GL_TEXTURE_2D,
0, RARCH_GL_INTERNAL_FORMAT, 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); pglActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);