mirror of
https://github.com/libretro/RetroArch
synced 2025-02-21 18:40:09 +00:00
Refactor gl_set_texture_frame
This commit is contained in:
parent
118ce66dec
commit
821a3283dc
@ -2785,7 +2785,8 @@ static bool gl_overlay_load(void *data,
|
||||
gl_load_texture_data(gl->overlay_tex[i],
|
||||
RARCH_WRAP_EDGE, TEXTURE_FILTER_LINEAR,
|
||||
alignment,
|
||||
images[i].width, images[i].height, images[i].pixels);
|
||||
images[i].width, images[i].height, images[i].pixels,
|
||||
sizeof(uint32_t));
|
||||
|
||||
/* Default. Stretch to whole screen. */
|
||||
gl_overlay_tex_geom(gl, i, 0, 0, 1, 1);
|
||||
@ -2991,7 +2992,7 @@ static void gl_set_texture_frame(void *data,
|
||||
const void *frame, bool rgb32, unsigned width, unsigned height,
|
||||
float alpha)
|
||||
{
|
||||
unsigned base_size;
|
||||
unsigned base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
|
||||
gl_t *gl = (gl_t*)data;
|
||||
if (!gl)
|
||||
return;
|
||||
@ -2999,38 +3000,18 @@ static void gl_set_texture_frame(void *data,
|
||||
context_bind_hw_render(gl, false);
|
||||
|
||||
if (!gl->menu_texture)
|
||||
{
|
||||
glGenTextures(1, &gl->menu_texture);
|
||||
glBindTexture(GL_TEXTURE_2D, gl->menu_texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
}
|
||||
else
|
||||
glBindTexture(GL_TEXTURE_2D, gl->menu_texture);
|
||||
|
||||
|
||||
gl_load_texture_data(gl->menu_texture,
|
||||
RARCH_WRAP_EDGE, TEXTURE_FILTER_LINEAR,
|
||||
video_pixel_get_alignment(width * base_size),
|
||||
width, height, frame,
|
||||
base_size);
|
||||
|
||||
gl->menu_texture_alpha = alpha;
|
||||
|
||||
base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(width * base_size));
|
||||
|
||||
if (rgb32)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
|
||||
width, height,
|
||||
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
||||
RARCH_GL_FORMAT32, frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0, GL_RGBA, width, height, 0, GL_RGBA,
|
||||
GL_UNSIGNED_SHORT_4_4_4_4, frame);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
||||
|
||||
context_bind_hw_render(gl, true);
|
||||
}
|
||||
|
||||
|
@ -21,11 +21,12 @@ void gl_load_texture_data(GLuint id,
|
||||
enum texture_filter_type filter_type,
|
||||
unsigned alignment,
|
||||
unsigned width, unsigned height,
|
||||
const void *frame)
|
||||
const void *frame, unsigned base_size)
|
||||
{
|
||||
GLint mag_filter, min_filter;
|
||||
GLenum wrap;
|
||||
bool want_mipmap = false;
|
||||
bool rgb32 = (base_size == (sizeof(uint32_t)));
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
|
||||
@ -69,10 +70,10 @@ void gl_load_texture_data(GLuint id,
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
|
||||
(driver.gfx_use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
|
||||
width, height, 0,
|
||||
driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
||||
RARCH_GL_FORMAT32, frame);
|
||||
(driver.gfx_use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
||||
(rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame);
|
||||
|
||||
if (want_mipmap)
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
@ -122,7 +123,7 @@ bool gl_load_luts(const struct video_shader *generic_shader,
|
||||
generic_shader->lut[i].wrap,
|
||||
filter_type, 4,
|
||||
img.width, img.height,
|
||||
img.pixels);
|
||||
img.pixels, sizeof(uint32_t));
|
||||
texture_image_free(&img);
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,8 @@ void gl_load_texture_data(GLuint id,
|
||||
enum texture_filter_type filter_type,
|
||||
unsigned alignment,
|
||||
unsigned width, unsigned height,
|
||||
const void *frame);
|
||||
const void *frame,
|
||||
unsigned base_size);
|
||||
|
||||
bool gl_load_luts(const struct video_shader *generic_shader,
|
||||
GLuint *lut_textures);
|
||||
|
@ -30,8 +30,11 @@ static void menu_texture_png_load_gl(struct texture_image *ti,
|
||||
/* Generate the OpenGL texture object */
|
||||
glGenTextures(1, id);
|
||||
gl_load_texture_data((GLuint)*id,
|
||||
RARCH_WRAP_EDGE, filter_type, 4 /* TODO/FIXME - dehardcode */,
|
||||
ti->width, ti->height, ti->pixels);
|
||||
RARCH_WRAP_EDGE, filter_type,
|
||||
4 /* TODO/FIXME - dehardcode */,
|
||||
ti->width, ti->height, ti->pixels,
|
||||
sizeof(uint32_t) /* TODO/FIXME - dehardcode */
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user