Take prototype declaration out of video_driver.h

This commit is contained in:
twinaphex 2016-03-23 06:57:29 +01:00
parent 69bcac61dd
commit e1c47a68fe
3 changed files with 70 additions and 72 deletions

View File

@ -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

View File

@ -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,

View File

@ -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;