bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures) { unsigned i, num_luts; num_luts = min(generic_shader->luts, GFX_MAX_TEXTURES); if (!generic_shader->luts) return true; // Original shader_glsl.c code only generated one texture handle. I assume // it was a bug, but if not, replace num_luts with 1 when GLSL is used. glGenTextures(num_luts, lut_textures); for (i = 0; i < num_luts; i++) { struct texture_image img = {0}; RARCH_LOG("Loading texture image from: \"%s\" ...\n", generic_shader->lut[i].path); if (!texture_image_load(&img, generic_shader->lut[i].path)) { RARCH_ERR("Failed to load texture image from: \"%s\"\n", generic_shader->lut[i].path); return false; } gl_load_texture_data(lut_textures[i], &img, gl_wrap_type_to_enum(generic_shader->lut[i].wrap), generic_shader->lut[i].filter != RARCH_FILTER_NEAREST, generic_shader->lut[i].mipmap); texture_image_free(&img); } glBindTexture(GL_TEXTURE_2D, 0); return true; }
static void video_texture_png_load_gl(struct texture_image *ti, enum texture_filter_type filter_type, unsigned *id) { /* Generate the OpenGL texture object */ glGenTextures(1, (GLuint*)id); gl_load_texture_data((GLuint)*id, RARCH_WRAP_EDGE, filter_type, 4 /* TODO/FIXME - dehardcode */, ti->width, ti->height, ti->pixels, sizeof(uint32_t) /* TODO/FIXME - dehardcode */ ); }
bool gl_load_luts(const struct video_shader *shader, GLuint *textures_lut) { unsigned i; unsigned num_luts = min(shader->luts, GFX_MAX_TEXTURES); if (!shader->luts) return true; glGenTextures(num_luts, textures_lut); for (i = 0; i < num_luts; i++) { struct texture_image img = {0}; enum texture_filter_type filter_type = TEXTURE_FILTER_LINEAR; RARCH_LOG("Loading texture image from: \"%s\" ...\n", shader->lut[i].path); if (!texture_image_load(&img, shader->lut[i].path)) { RARCH_ERR("Failed to load texture image from: \"%s\"\n", shader->lut[i].path); return false; } if (shader->lut[i].filter == RARCH_FILTER_NEAREST) filter_type = TEXTURE_FILTER_NEAREST; if (shader->lut[i].mipmap) { if (filter_type == TEXTURE_FILTER_NEAREST) filter_type = TEXTURE_FILTER_MIPMAP_NEAREST; else filter_type = TEXTURE_FILTER_MIPMAP_LINEAR; } gl_load_texture_data(textures_lut[i], shader->lut[i].wrap, filter_type, 4, img.width, img.height, img.pixels, sizeof(uint32_t)); texture_image_free(&img); } glBindTexture(GL_TEXTURE_2D, 0); return true; }
bool gl_renderchain_add_lut(const struct video_shader *shader, unsigned i, GLuint *textures_lut) { struct texture_image img = {0}; enum texture_filter_type filter_type = TEXTURE_FILTER_LINEAR; if (!image_texture_load(&img, shader->lut[i].path)) { RARCH_ERR("Failed to load texture image from: \"%s\"\n", shader->lut[i].path); return false; } RARCH_LOG("Loaded texture image from: \"%s\" ...\n", shader->lut[i].path); if (shader->lut[i].filter == RARCH_FILTER_NEAREST) filter_type = TEXTURE_FILTER_NEAREST; if (shader->lut[i].mipmap) { if (filter_type == TEXTURE_FILTER_NEAREST) filter_type = TEXTURE_FILTER_MIPMAP_NEAREST; else filter_type = TEXTURE_FILTER_MIPMAP_LINEAR; } gl_load_texture_data(textures_lut[i], shader->lut[i].wrap, filter_type, 4, img.width, img.height, img.pixels, sizeof(uint32_t)); image_texture_free(&img); return true; }