diff --git a/gfx/gl.c b/gfx/gl.c index bfb08e138c..aeec6b9056 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -31,14 +31,7 @@ #include "config.h" #endif -#ifdef __APPLE__ -#include -#include -#else -#define GL_GLEXT_PROTOTYPES -#include -#include -#endif +#include "gl_common.h" #define NO_SDL_GLEXT #include "SDL.h" @@ -53,7 +46,6 @@ #include "shader_glsl.h" #endif -#include "gl_common.h" #ifdef HAVE_FREETYPE #include "fonts.h" @@ -119,6 +111,7 @@ typedef struct gl // Render-to-texture, multipass shaders GLuint fbo[MAX_SHADERS]; GLuint fbo_texture[MAX_SHADERS]; + struct gl_fbo_rect fbo_rect[MAX_SHADERS]; bool render_to_tex; unsigned fbo_width; unsigned fbo_height; @@ -264,17 +257,33 @@ static inline unsigned gl_shader_num(void) return num; } -static inline bool gl_shader_filter_type(unsigned num, bool *smooth) +static inline bool gl_shader_filter_type(unsigned index, bool *smooth) { bool valid = false; #ifdef HAVE_CG if (!valid) - valid = gl_cg_filter_type(num, smooth); + valid = gl_cg_filter_type(index, smooth); #endif #ifdef HAVE_XML if (!valid) - valid = gl_glsl_filter_type(num, smooth); + valid = gl_glsl_filter_type(index, smooth); +#endif + + return valid; +} + +static inline bool gl_shader_rect(unsigned index, struct gl_fbo_rect *rect) +{ + bool valid = false; +#ifdef HAVE_CG + if (!valid) + valid = gl_cg_shader_rect(index, rect); +#endif + +#ifdef HAVE_XML + if (!valid) + valid = gl_glsl_shader_rect(index, rect); #endif return valid; diff --git a/gfx/gl_common.h b/gfx/gl_common.h index f03ee6a799..c0dcce57c6 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -20,6 +20,15 @@ #include "general.h" +#ifdef __APPLE__ +#include +#include +#else +#define GL_GLEXT_PROTOTYPES +#include +#include +#endif + static inline bool gl_check_error(void) { int error = glGetError(); @@ -29,7 +38,7 @@ static inline bool gl_check_error(void) SSNES_ERR("GL: Invalid enum.\n"); break; case GL_INVALID_VALUE: - SSNES_ERR("GL: Invalid value.\n"); + SSNES_ERR("GL: Invalid value. (You're not alone.)\n"); break; case GL_INVALID_OPERATION: SSNES_ERR("GL: Invalid operation.\n"); @@ -56,4 +65,14 @@ static inline bool gl_check_error(void) return false; } +struct gl_fbo_rect +{ + unsigned width; + unsigned height; + unsigned tex_width; + unsigned tex_height; + + GLfloat texcoord[8]; +}; + #endif diff --git a/gfx/shader_cg.c b/gfx/shader_cg.c index 0e890ada18..a00053012a 100644 --- a/gfx/shader_cg.c +++ b/gfx/shader_cg.c @@ -208,3 +208,11 @@ bool gl_cg_filter_type(unsigned index, bool *smooth) // We don't really care since .cg doesn't have those kinds of semantics by itself ... return false; } + +bool gl_cg_shader_rect(unsigned index, struct gl_fbo_rect *rect) +{ + (void)index; + (void)rect; + // We don't really care since .cg doesn't have those kinds of semantics by itself ... + return false; +} diff --git a/gfx/shader_cg.h b/gfx/shader_cg.h index 54c2b08447..8dd24d6e04 100644 --- a/gfx/shader_cg.h +++ b/gfx/shader_cg.h @@ -20,6 +20,7 @@ #define __SSNES_CG_H #include +#include "gl_common.h" bool gl_cg_init(const char *path); @@ -36,5 +37,6 @@ void gl_cg_use(unsigned index); unsigned gl_cg_num(void); bool gl_cg_filter_type(unsigned index, bool *smooth); +bool gl_cg_shader_rect(unsigned index, struct gl_fbo_rect *rect); #endif diff --git a/gfx/shader_glsl.c b/gfx/shader_glsl.c index 59d2019cf6..8fd666bdd9 100644 --- a/gfx/shader_glsl.c +++ b/gfx/shader_glsl.c @@ -420,3 +420,10 @@ bool gl_glsl_filter_type(unsigned index, bool *smooth) return false; } } + +bool gl_glsl_shader_rect(unsigned index, struct gl_fbo_rect *rect) +{ + (void)index; + (void)rect; + return false; +} diff --git a/gfx/shader_glsl.h b/gfx/shader_glsl.h index d570b3ebaa..78301f8b76 100644 --- a/gfx/shader_glsl.h +++ b/gfx/shader_glsl.h @@ -36,5 +36,6 @@ void gl_glsl_use(unsigned index); unsigned gl_glsl_num(void); bool gl_glsl_filter_type(unsigned index, bool *smooth); +bool gl_glsl_shader_rect(unsigned index, struct gl_fbo_rect *rect); #endif