From e1c47a68fe8e1d12070a69478f9e74fe62bbe5da Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 23 Mar 2016 06:57:29 +0100 Subject: [PATCH] Take prototype declaration out of video_driver.h --- gfx/common/gl_common.c | 7 +++ gfx/drivers/gl.c | 125 +++++++++++++++++++++-------------------- gfx/video_driver.h | 10 ---- 3 files changed, 70 insertions(+), 72 deletions(-) diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c index 4aef61abd5..0303f060cb 100644 --- a/gfx/common/gl_common.c +++ b/gfx/common/gl_common.c @@ -16,6 +16,13 @@ #include "gl_common.h" +extern 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_ff_vertex(const void *data) { #ifndef NO_GL_FF_VERTEX diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 9b4e36cd79..cda476cda2 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3358,6 +3358,69 @@ unsigned *height_p, size_t *pitch_p) } #endif +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_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL); + bool rgb32 = (base_size == (sizeof(uint32_t))); + GLenum wrap = gl_wrap_type_to_enum(wrap_type); + GLuint id = (GLuint)id_data; + + glBindTexture(GL_TEXTURE_2D, id); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); + +#if defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) || defined(OSX_PPC) + if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) + filter_type = TEXTURE_FILTER_LINEAR; + if (filter_type == TEXTURE_FILTER_MIPMAP_NEAREST) + filter_type = TEXTURE_FILTER_NEAREST; +#endif + + 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; + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_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) + glGenerateMipmap(GL_TEXTURE_2D); +} + #ifdef HAVE_OVERLAY static void gl_free_overlay(gl_t *gl); static bool gl_overlay_load(void *data, @@ -3741,68 +3804,6 @@ static void gl_get_video_output_next(void *data) gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); } -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_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL); - bool rgb32 = (base_size == (sizeof(uint32_t))); - GLenum wrap = gl_wrap_type_to_enum(wrap_type); - GLuint id = (GLuint)id_data; - - glBindTexture(GL_TEXTURE_2D, id); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); - -#if defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) || defined(OSX_PPC) - if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) - filter_type = TEXTURE_FILTER_LINEAR; - if (filter_type == TEXTURE_FILTER_MIPMAP_NEAREST) - filter_type = TEXTURE_FILTER_NEAREST; -#endif - - 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; - } - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_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) - glGenerateMipmap(GL_TEXTURE_2D); -} static void video_texture_load_gl( struct texture_image *ti, diff --git a/gfx/video_driver.h b/gfx/video_driver.h index bdb0bcec7f..42b8e183f5 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -540,16 +540,6 @@ bool video_driver_texture_load(void *data, bool video_driver_texture_unload(uintptr_t *id); -#ifdef HAVE_OPENGL -void gl_load_texture_data(uint32_t id, - enum gfx_wrap_type wrap_type, - enum texture_filter_type filter_type, - unsigned alignment, - unsigned width, unsigned height, - const void *frame, - unsigned base_size); -#endif - extern video_driver_t video_gl; extern video_driver_t video_vulkan; extern video_driver_t video_psp1;