diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c index 0c40e5cff4..f58615c715 100644 --- a/gfx/common/gl_common.c +++ b/gfx/common/gl_common.c @@ -80,6 +80,75 @@ void gl_load_texture_image(GLenum target, } } +void gl_load_texture_data( + uint32_t id_data, + enum gfx_wrap_type wrap_type, + enum texture_filter_type filter_type, + unsigned alignment, + unsigned width, unsigned height, + const void *frame, unsigned base_size) +{ + GLint mag_filter, min_filter; + bool want_mipmap = false; + bool use_rgba = video_driver_supports_rgba(); + bool rgb32 = (base_size == (sizeof(uint32_t))); + GLenum wrap = gl_wrap_type_to_enum(wrap_type); + GLuint id = (GLuint)id_data; + bool have_mipmap = gl_check_capability(GL_CAPS_MIPMAP); + + if (!have_mipmap) + { + /* Assume no mipmapping support. */ + switch (filter_type) + { + case TEXTURE_FILTER_MIPMAP_LINEAR: + filter_type = TEXTURE_FILTER_LINEAR; + break; + case TEXTURE_FILTER_MIPMAP_NEAREST: + filter_type = TEXTURE_FILTER_NEAREST; + break; + default: + break; + } + } + + switch (filter_type) + { + case TEXTURE_FILTER_MIPMAP_LINEAR: + min_filter = GL_LINEAR_MIPMAP_NEAREST; + mag_filter = GL_LINEAR; + want_mipmap = true; + break; + case TEXTURE_FILTER_MIPMAP_NEAREST: + min_filter = GL_NEAREST_MIPMAP_NEAREST; + mag_filter = GL_NEAREST; + want_mipmap = true; + break; + case TEXTURE_FILTER_NEAREST: + min_filter = GL_NEAREST; + mag_filter = GL_NEAREST; + break; + case TEXTURE_FILTER_LINEAR: + default: + min_filter = GL_LINEAR; + mag_filter = GL_LINEAR; + break; + } + + gl_bind_texture(id, wrap, mag_filter, min_filter); + + glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); + glTexImage2D(GL_TEXTURE_2D, + 0, + (use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, + width, height, 0, + (use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, + (rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame); + + if (want_mipmap && have_mipmap) + glGenerateMipmap(GL_TEXTURE_2D); +} + bool gl_add_lut( const char *lut_path, bool lut_mipmap, diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 3290fb471f..eb95f6589c 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -600,74 +600,6 @@ static INLINE void gl_set_shader_viewports(gl_t *gl) } } -void gl_load_texture_data( - uint32_t id_data, - enum gfx_wrap_type wrap_type, - enum texture_filter_type filter_type, - unsigned alignment, - unsigned width, unsigned height, - const void *frame, unsigned base_size) -{ - GLint mag_filter, min_filter; - bool want_mipmap = false; - bool use_rgba = video_driver_supports_rgba(); - bool rgb32 = (base_size == (sizeof(uint32_t))); - GLenum wrap = gl_wrap_type_to_enum(wrap_type); - GLuint id = (GLuint)id_data; - bool have_mipmap = gl_check_capability(GL_CAPS_MIPMAP); - - if (!have_mipmap) - { - /* Assume no mipmapping support. */ - switch (filter_type) - { - case TEXTURE_FILTER_MIPMAP_LINEAR: - filter_type = TEXTURE_FILTER_LINEAR; - break; - case TEXTURE_FILTER_MIPMAP_NEAREST: - filter_type = TEXTURE_FILTER_NEAREST; - break; - default: - break; - } - } - - switch (filter_type) - { - case TEXTURE_FILTER_MIPMAP_LINEAR: - min_filter = GL_LINEAR_MIPMAP_NEAREST; - mag_filter = GL_LINEAR; - want_mipmap = true; - break; - case TEXTURE_FILTER_MIPMAP_NEAREST: - min_filter = GL_NEAREST_MIPMAP_NEAREST; - mag_filter = GL_NEAREST; - want_mipmap = true; - break; - case TEXTURE_FILTER_NEAREST: - min_filter = GL_NEAREST; - mag_filter = GL_NEAREST; - break; - case TEXTURE_FILTER_LINEAR: - default: - min_filter = GL_LINEAR; - mag_filter = GL_LINEAR; - break; - } - - gl_bind_texture(id, wrap, mag_filter, min_filter); - - glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); - glTexImage2D(GL_TEXTURE_2D, - 0, - (use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, - width, height, 0, - (use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, - (rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame); - - if (want_mipmap && have_mipmap) - glGenerateMipmap(GL_TEXTURE_2D); -} static void gl_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 1e877e17c9..16de31242b 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -165,14 +165,6 @@ static void gl2_renderchain_bind_backbuffer(void *data, void context_bind_hw_render(void *data, bool enable); -void gl_load_texture_data( - uint32_t id_data, - enum gfx_wrap_type wrap_type, - enum texture_filter_type filter_type, - unsigned alignment, - unsigned width, unsigned height, - const void *frame, unsigned base_size); - void gl_set_viewport( gl_t *gl, video_frame_info_t *video_info, unsigned viewport_width,