(PS3) Automatic aspect ratio based on game width/height works

now
This commit is contained in:
Twinaphex 2012-05-22 18:23:58 +02:00
parent e7e0b9ca27
commit 03f081ace6
4 changed files with 31 additions and 0 deletions

View File

@ -490,6 +490,25 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = {
{ "Custom", 0.0f }
};
void rarch_set_auto_viewport(unsigned width, unsigned height)
{
unsigned aspect_x, aspect_y, len, highest, i;
len = width < height ? width : height;
highest = 1;
for (i = 1; i < len; i++)
{
if ((width % i) == 0 && (height % i) == 0)
highest = i;
}
aspect_x = width / highest;
aspect_y = height / highest;
snprintf(aspectratio_lut[ASPECT_RATIO_AUTO].name, sizeof(aspectratio_lut[ASPECT_RATIO_AUTO].name), "%d:%d (Auto)", aspect_x, aspect_y);
aspectratio_lut[ASPECT_RATIO_AUTO].value = (int)aspect_x / (int)aspect_y;
}
/*============================================================
LIBRETRO
============================================================ */

View File

@ -61,6 +61,8 @@ struct aspect_ratio_elem
extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END];
extern void rarch_set_auto_viewport(unsigned width, unsigned height);
#include "console_ext_input.h"
/*============================================================

View File

@ -523,6 +523,8 @@ begin_loop:
input_ps3.poll(NULL);
rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height);
do{
repeat = rarch_main_iterate();
}while(repeat && !g_console.frame_advance_enable);

View File

@ -557,6 +557,9 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
GLfloat yamt = (GLfloat)height / gl->tex_h;
set_texture_coords(gl->tex_coords, xamt, yamt);
if(g_console.aspect_ratio_index == ASPECT_RATIO_AUTO )
rarch_set_auto_viewport(width, height);
}
else if (width != gl->last_width[(gl->tex_index - 1) & TEXTURES_MASK] || height != gl->last_height[(gl->tex_index - 1) & TEXTURES_MASK])
{
@ -983,9 +986,14 @@ static void ps3graphics_set_aspect_ratio(void * data, uint32_t aspectratio_index
(void)data;
gl_t * gl = g_gl;
if(g_console.aspect_ratio_index == ASPECT_RATIO_AUTO)
rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height);
g_settings.video.aspect_ratio = aspectratio_lut[g_console.aspect_ratio_index].value;
g_settings.video.force_aspect = false;
gl->keep_aspect = true;
set_viewport(gl, gl->win_width, gl->win_height);
}