From 89e449cc86cd7e76a4724710d52b851d91625c26 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 2 Oct 2014 11:27:11 +0200 Subject: [PATCH] Get rid of header dependencies on GL in shader_common.h --- frontend/menu/disp/glui.c | 1 + gfx/gl_common.h | 3 +- gfx/shader/shader_cg.c | 4 +++ gfx/shader/shader_common.c | 2 ++ gfx/shader/shader_common.h | 62 +++++++++++++++-------------------- gfx/shader/shader_gl_common.h | 28 ++++++++++++++++ gfx/shader/shader_glsl.c | 4 ++- gfx/shader/shader_null.c | 2 -- 8 files changed, 65 insertions(+), 41 deletions(-) create mode 100644 gfx/shader/shader_gl_common.h diff --git a/frontend/menu/disp/glui.c b/frontend/menu/disp/glui.c index eac83fe896..6bfaa2d4b7 100644 --- a/frontend/menu/disp/glui.c +++ b/frontend/menu/disp/glui.c @@ -27,6 +27,7 @@ #include "../backend/menu_common_backend.h" #include "../../../general.h" #include "../../../gfx/gfx_common.h" +#include "../../../gfx/shader/shader_gl_common.h" #include "../../../config.def.h" #include "../../../file.h" #include "../../../dynamic.h" diff --git a/gfx/gl_common.h b/gfx/gl_common.h index ceb7c0b689..89ea0596bb 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -22,6 +22,7 @@ #include "gfx_context.h" #include "scaler/scaler.h" #include "fonts/gl_font.h" +#include "shader/shader_common.h" #include "shader/shader_parse.h" #ifdef HAVE_CONFIG_H @@ -167,8 +168,6 @@ struct gl_coords unsigned vertices; }; -typedef struct shader_backend shader_backend_t; - #define MAX_SHADERS 16 #define MAX_TEXTURES 8 diff --git a/gfx/shader/shader_cg.c b/gfx/shader/shader_cg.c index de9ed4581b..a60a8b3c97 100644 --- a/gfx/shader/shader_cg.c +++ b/gfx/shader/shader_cg.c @@ -18,6 +18,10 @@ #pragma comment(lib, "cggl") #endif +#ifdef HAVE_OPENGL +#include "shader_gl_common.h" +#endif + #include "shader_cg.h" #include "shader_common.h" #include diff --git a/gfx/shader/shader_common.c b/gfx/shader/shader_common.c index 90f9ace947..d76fe8214b 100644 --- a/gfx/shader/shader_common.c +++ b/gfx/shader/shader_common.c @@ -17,6 +17,8 @@ #include "../../retroarch_logger.h" #ifdef HAVE_OPENGL +#include "shader_gl_common.h" + void gl_load_texture_data(GLuint obj, const struct texture_image *img, GLenum wrap, bool linear, bool mipmap) { diff --git a/gfx/shader/shader_common.h b/gfx/shader/shader_common.h index 0a25de0655..617c0c399b 100644 --- a/gfx/shader/shader_common.h +++ b/gfx/shader/shader_common.h @@ -1,5 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2014 - Daniel De Matteis * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- @@ -13,8 +14,8 @@ * If not, see . */ -#ifndef SHADER_COMMON_H__ -#define SHADER_COMMON_H__ +#ifndef SHADERS_COMMON_H__ +#define SHADERS_COMMON_H__ #include "../../boolean.h" @@ -22,37 +23,10 @@ #include "../../config.h" #endif -#ifdef HAVE_OPENGL -#include "../gl_common.h" -#endif - #include "../gfx_context.h" #include "../math/matrix.h" -#if defined(_XBOX360) -#define DEFAULT_SHADER_TYPE RARCH_SHADER_HLSL -#elif defined(__PSL1GHT__) -#define DEFAULT_SHADER_TYPE RARCH_SHADER_GLSL -#elif defined(__CELLOS_LV2__) -#define DEFAULT_SHADER_TYPE RARCH_SHADER_CG -#elif defined(HAVE_OPENGLES2) -#define DEFAULT_SHADER_TYPE RARCH_SHADER_GLSL -#else -#define DEFAULT_SHADER_TYPE RARCH_SHADER_NONE -#endif - -#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) -#ifndef HAVE_SHADER_MANAGER -#define HAVE_SHADER_MANAGER -#endif - -#include "shader_parse.h" - -#define GL_SHADER_STOCK_BLEND (GFX_MAX_SHADERS - 1) - -#endif - -struct shader_backend +typedef struct shader_backend { bool (*init)(void *data, const char *path); void (*deinit)(void); @@ -77,18 +51,34 @@ struct shader_backend struct gfx_shader *(*get_current_shader)(void); enum rarch_shader_type type; -}; +} shader_backend_t; extern const shader_backend_t gl_glsl_backend; extern const shader_backend_t hlsl_backend; extern const shader_backend_t gl_cg_backend; extern const shader_backend_t shader_null_backend; -#ifdef HAVE_OPENGL -void gl_load_texture_data(GLuint obj, const struct texture_image *img, - GLenum wrap, bool linear, bool mipmap); -bool gl_load_luts(const struct gfx_shader *generic_shader, - GLuint *lut_textures); +#if defined(_XBOX360) +#define DEFAULT_SHADER_TYPE RARCH_SHADER_HLSL +#elif defined(__PSL1GHT__) +#define DEFAULT_SHADER_TYPE RARCH_SHADER_GLSL +#elif defined(__CELLOS_LV2__) +#define DEFAULT_SHADER_TYPE RARCH_SHADER_CG +#elif defined(HAVE_OPENGLES2) +#define DEFAULT_SHADER_TYPE RARCH_SHADER_GLSL +#else +#define DEFAULT_SHADER_TYPE RARCH_SHADER_NONE +#endif + +#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) +#ifndef HAVE_SHADER_MANAGER +#define HAVE_SHADER_MANAGER +#endif + +#include "shader_parse.h" + +#define GL_SHADER_STOCK_BLEND (GFX_MAX_SHADERS - 1) + #endif #endif diff --git a/gfx/shader/shader_gl_common.h b/gfx/shader/shader_gl_common.h new file mode 100644 index 0000000000..1a26e6cf54 --- /dev/null +++ b/gfx/shader/shader_gl_common.h @@ -0,0 +1,28 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2014 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef SHADERS_GL_COMMON_H__ +#define SHADERS_GL_COMMON_H__ + +#include "../gl_common.h" + +void gl_load_texture_data(GLuint obj, const struct texture_image *img, + GLenum wrap, bool linear, bool mipmap); + +bool gl_load_luts(const struct gfx_shader *generic_shader, + GLuint *lut_textures); + +#endif diff --git a/gfx/shader/shader_glsl.c b/gfx/shader/shader_glsl.c index da79d17a87..fa08aa8fbc 100644 --- a/gfx/shader/shader_glsl.c +++ b/gfx/shader/shader_glsl.c @@ -32,7 +32,9 @@ #include "../gfx_context.h" #include -#include "../gl_common.h" +#ifdef HAVE_OPENGL +#include "shader_gl_common.h" +#endif #ifdef HAVE_OPENGLES2 #define BORDER_FUNC GL_CLAMP_TO_EDGE diff --git a/gfx/shader/shader_null.c b/gfx/shader/shader_null.c index 66cf152128..9c818ef0ce 100644 --- a/gfx/shader/shader_null.c +++ b/gfx/shader/shader_null.c @@ -32,8 +32,6 @@ #include "shader_common.h" #include -typedef struct shader_backend shader_backend_t; - static void shader_null_deinit(void) { } static bool shader_null_init(void *data, const char *path) { return true; }