Works quite decently now. :)

This commit is contained in:
Themaister 2011-03-14 23:59:31 +01:00
parent 56ac7b4649
commit 898c4e8c6c
2 changed files with 12 additions and 3 deletions

View File

@ -573,6 +573,7 @@ static bool gl_frame(void *data, const void* frame, unsigned width, unsigned hei
// Render to texture in first pass.
if (gl->fbo_inited)
{
// Calculate viewports for FBOs.
for (int i = 0; i < gl->fbo_pass; i++)
{
gl->fbo_rect[i].img_width = width * gl->fbo_scale[i].scale_x;
@ -634,9 +635,11 @@ static bool gl_frame(void *data, const void* frame, unsigned width, unsigned hei
// Render the rest of our passes.
glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), gl->fbo_tex_coords);
// It's kinda handy ... :)
const struct gl_fbo_rect *prev_rect;
const struct gl_fbo_rect *rect;
// Calculate viewports, texture coordinates etc, and render all passes from FBOs, to another FBO.
for (int i = 1; i < gl->fbo_pass; i++)
{
prev_rect = &gl->fbo_rect[i - 1];
@ -654,12 +657,15 @@ static bool gl_frame(void *data, const void* frame, unsigned width, unsigned hei
gl_shader_use(i + 1);
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]);
set_viewport(gl, rect->img_width, rect->img_height, true);
glClear(GL_COLOR_BUFFER_BIT);
// Render to FBO with certain size.
set_viewport(gl, rect->img_width, rect->img_height, true);
gl_shader_set_params(prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, gl->vp_width, gl->vp_height);
glDrawArrays(GL_QUADS, 0, 4);
}
// Render our last FBO texture directly to screen.
prev_rect = &gl->fbo_rect[gl->fbo_pass - 1];
GLfloat xamt = (GLfloat)prev_rect->img_width / prev_rect->width;
GLfloat yamt = (GLfloat)prev_rect->img_height / prev_rect->height;

View File

@ -133,6 +133,7 @@ static void get_xml_attrs(struct shader_program *prog, xmlNodePtr ptr)
xmlChar *attr_scale = xmlGetProp(ptr, (const xmlChar*)"scale");
xmlChar *attr_scale_x = xmlGetProp(ptr, (const xmlChar*)"scale_x");
xmlChar *attr_scale_y = xmlGetProp(ptr, (const xmlChar*)"scale_y");
if (attr_scale)
{
float scale = strtod((const char*)attr_scale, NULL);
@ -141,14 +142,16 @@ static void get_xml_attrs(struct shader_program *prog, xmlNodePtr ptr)
prog->valid_scale = true;
SSNES_LOG("Got scale attr: %.1f\n", scale);
}
else if (attr_scale_x)
if (attr_scale_x)
{
float scale = strtod((const char*)attr_scale_x, NULL);
prog->scale_x = scale;
prog->valid_scale = true;
SSNES_LOG("Got scale_x attr: %.1f\n", scale);
}
else if (attr_scale_y)
if (attr_scale_y)
{
float scale = strtod((const char*)attr_scale_y, NULL);
prog->scale_y = scale;