mirror of https://github.com/snes9xgit/snes9x.git
GLSL: Use a viewport callback to size final pass.
This commit is contained in:
parent
206523ee17
commit
b9b60a8e60
|
@ -14,6 +14,21 @@
|
||||||
#include "shaders/shader_helpers.h"
|
#include "shaders/shader_helpers.h"
|
||||||
#include "shaders/CGLCG.h"
|
#include "shaders/CGLCG.h"
|
||||||
|
|
||||||
|
static void S9xViewportCallback (int src_width, int src_height,
|
||||||
|
int viewport_x, int viewport_y,
|
||||||
|
int viewport_width, int viewport_height,
|
||||||
|
int *out_x, int *out_y,
|
||||||
|
int *out_width, int *out_height)
|
||||||
|
{
|
||||||
|
|
||||||
|
S9xApplyAspect (src_width, src_height, viewport_width, viewport_height);
|
||||||
|
*out_x = src_width + viewport_x;
|
||||||
|
*out_y = src_height + viewport_y;
|
||||||
|
*out_width = viewport_width;
|
||||||
|
*out_height = viewport_height;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
S9xOpenGLDisplayDriver::S9xOpenGLDisplayDriver (Snes9xWindow *window,
|
S9xOpenGLDisplayDriver::S9xOpenGLDisplayDriver (Snes9xWindow *window,
|
||||||
Snes9xConfig *config)
|
Snes9xConfig *config)
|
||||||
{
|
{
|
||||||
|
@ -226,7 +241,7 @@ S9xOpenGLDisplayDriver::update (int width, int height, int yoffset)
|
||||||
|
|
||||||
if (using_shaders && using_glsl_shaders)
|
if (using_shaders && using_glsl_shaders)
|
||||||
{
|
{
|
||||||
glsl_shader->render (texmap, width, height, w, h, x, allocation.height - y - h);
|
glsl_shader->render (texmap, width, height, x, allocation.height - y - h, w, h, S9xViewportCallback);
|
||||||
gl_swap ();
|
gl_swap ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,7 +552,11 @@ bool GLSLShader::load_shader (char *filename)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLSLShader::render(GLuint &orig, int width, int height, int viewport_width, int viewport_height, int viewport_x, int viewport_y)
|
void GLSLShader::render(GLuint &orig,
|
||||||
|
int width, int height,
|
||||||
|
int viewport_x, int viewport_y,
|
||||||
|
int viewport_width, int viewport_height,
|
||||||
|
GLSLViewportCallback vpcallback)
|
||||||
{
|
{
|
||||||
frame_count++;
|
frame_count++;
|
||||||
|
|
||||||
|
@ -641,9 +645,19 @@ void GLSLShader::render(GLuint &orig, int width, int height, int viewport_width,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int out_x = 0;
|
||||||
|
int out_y = 0;
|
||||||
|
int out_width = 0;
|
||||||
|
int out_height = 0;
|
||||||
|
|
||||||
// output to the screen
|
// output to the screen
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
|
vpcallback (pass[i].width, pass[i].height,
|
||||||
|
viewport_x, viewport_y,
|
||||||
|
viewport_width, viewport_height,
|
||||||
|
&out_x, &out_y,
|
||||||
|
&out_width, &out_height);
|
||||||
|
glViewport(out_x, out_y, out_width, out_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up input texture (output of previous pass) and apply filter settings
|
// set up input texture (output of previous pass) and apply filter settings
|
||||||
|
|
|
@ -6,6 +6,12 @@
|
||||||
|
|
||||||
static const unsigned int glsl_max_passes = 20;
|
static const unsigned int glsl_max_passes = 20;
|
||||||
|
|
||||||
|
typedef void (* GLSLViewportCallback) (int source_width, int source_height,
|
||||||
|
int viewport_x, int viewport_y,
|
||||||
|
int viewport_width, int viewport_height,
|
||||||
|
int *out_dst_x, int *out_dst_y,
|
||||||
|
int *out_dst_width, int *out_dst_height);
|
||||||
|
|
||||||
enum GLSLScaleType
|
enum GLSLScaleType
|
||||||
{
|
{
|
||||||
GLSL_NONE = 0,
|
GLSL_NONE = 0,
|
||||||
|
@ -107,7 +113,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
bool load_shader (char *filename);
|
bool load_shader (char *filename);
|
||||||
bool load_shader_file (char *filename);
|
bool load_shader_file (char *filename);
|
||||||
void render (GLuint &orig, int width, int height, int viewport_width, int viewport_height, int viewport_x, int viewport_y);
|
void render (GLuint &orig, int width, int height, int viewport_width, int viewport_height, int viewport_x, int viewport_y, GLSLViewportCallback vpcallback);
|
||||||
void set_shader_vars (unsigned int pass);
|
void set_shader_vars (unsigned int pass);
|
||||||
void clear_shader_vars (void);
|
void clear_shader_vars (void);
|
||||||
void strip_parameter_pragmas(char *buffer);
|
void strip_parameter_pragmas(char *buffer);
|
||||||
|
|
Loading…
Reference in New Issue