Refactor aspect ratio handling.

Rework aspect ratio handling in RGUI.
Custom viewports work on PC. Ensure that aspect_ratio_idx persist
through reentrancy. Change ASPECT_RATIO_AUTO to ASPECT_RATIO_SQUARE to
better signal that it's the square pixel option.

Add ASPECT_RATIO_CONFIG as an option to use config file defined aspect
ratio.
This commit is contained in:
Themaister 2013-04-20 10:56:04 +02:00
parent f1e3cb3b58
commit be01a0ea59
10 changed files with 162 additions and 126 deletions

View File

@ -266,11 +266,13 @@ static const bool aspect_ratio_auto = false; // 1:1 PAR
#if defined(__CELLOS_LV2) || defined(_XBOX360) #if defined(__CELLOS_LV2) || defined(_XBOX360)
static unsigned aspect_ratio_idx = ASPECT_RATIO_16_9; static unsigned aspect_ratio_idx = ASPECT_RATIO_16_9;
#else #elif defined(RARCH_CONSOLE)
static unsigned aspect_ratio_idx = ASPECT_RATIO_4_3; static unsigned aspect_ratio_idx = ASPECT_RATIO_4_3;
#else
static unsigned aspect_ratio_idx = ASPECT_RATIO_CONFIG; // Use g_settings.video.aspect_ratio.
#endif #endif
// Crop overscanned frames (7/8 or 15/15 for interlaced frames). // Crop overscanned frames.
static const bool crop_overscan = true; static const bool crop_overscan = true;
// Font size for on-screen messages. // Font size for on-screen messages.

View File

@ -24,6 +24,7 @@
#include "audio/utils.h" #include "audio/utils.h"
#include "audio/resampler.h" #include "audio/resampler.h"
#include "gfx/thread_wrapper.h" #include "gfx/thread_wrapper.h"
#include "gfx/gfx_common.h"
#ifdef HAVE_X11 #ifdef HAVE_X11
#include "gfx/context/x11_common.h" #include "gfx/context/x11_common.h"
@ -945,6 +946,10 @@ void init_video_input(void)
if (driver.video->set_rotation && g_extern.system.rotation) if (driver.video->set_rotation && g_extern.system.rotation)
video_set_rotation_func(g_extern.system.rotation); video_set_rotation_func(g_extern.system.rotation);
if (driver.video_poke->set_aspect_ratio &&
g_settings.video.aspect_ratio_idx != ASPECT_RATIO_CONFIG)
driver.video_poke->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx);
#ifdef HAVE_X11 #ifdef HAVE_X11
if (driver.display_type == RARCH_DISPLAY_X11) if (driver.display_type == RARCH_DISPLAY_X11)
{ {

View File

@ -476,14 +476,21 @@ bool menu_iterate(void)
rgui->old_input_state = input_state; rgui->old_input_state = input_state;
input_entry_ret = rgui_iterate(rgui); input_entry_ret = rgui_iterate(rgui);
#ifdef HAVE_RGUI
#define MENU_TEXTURE_FULLSCREEN false
#else
#define MENU_TEXTURE_FULLSCREEN true
#endif
// draw last frame for loading messages // draw last frame for loading messages
if (driver.video_poke && driver.video_poke->set_texture_enable) if (driver.video_poke && driver.video_poke->set_texture_enable)
driver.video_poke->set_texture_enable(driver.video_data, rgui->frame_buf_show, true); driver.video_poke->set_texture_enable(driver.video_data, rgui->frame_buf_show, MENU_TEXTURE_FULLSCREEN);
rarch_render_cached_frame(); rarch_render_cached_frame();
if (driver.video_poke && driver.video_poke->set_texture_enable) if (driver.video_poke && driver.video_poke->set_texture_enable)
driver.video_poke->set_texture_enable(driver.video_data, false, true); driver.video_poke->set_texture_enable(driver.video_data, false,
MENU_TEXTURE_FULLSCREEN);
if (rgui_input_postprocess(rgui, rgui->old_input_state) || input_entry_ret) if (rgui_input_postprocess(rgui, rgui->old_input_state) || input_entry_ret)
goto deinit; goto deinit;

View File

@ -216,6 +216,12 @@ rgui_handle_t *rgui_init(void)
rgui->selection_ptr = 0; rgui->selection_ptr = 0;
rgui_settings_populate_entries(rgui); rgui_settings_populate_entries(rgui);
// Make sure that custom viewport is something sane incase we use it
// before it's configured.
rarch_viewport_t *custom = &g_extern.console.screen.viewports.custom_vp;
if (driver.video_data && (!custom->width || !custom->height))
driver.video->viewport_info(driver.video_data, custom);
return rgui; return rgui;
} }
@ -1350,26 +1356,21 @@ static void rgui_settings_controller_populate_entries(rgui_handle_t *rgui)
static int rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action) static int rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action)
{ {
rarch_viewport_t vp; rarch_viewport_t *custom = &g_extern.console.screen.viewports.custom_vp;
driver.video->viewport_info(driver.video_data, &vp);
unsigned win_width = vp.full_width;
unsigned win_height = vp.full_height;
unsigned menu_type = 0; unsigned menu_type = 0;
rgui_list_get_last(rgui->menu_stack, NULL, &menu_type); rgui_list_get_last(rgui->menu_stack, NULL, &menu_type);
(void)win_width;
(void)win_height;
switch (action) switch (action)
{ {
case RGUI_ACTION_UP: case RGUI_ACTION_UP:
if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT) if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT)
{ {
g_extern.console.screen.viewports.custom_vp.y -= 1; custom->y -= 1;
g_extern.console.screen.viewports.custom_vp.height += 1; custom->height += 1;
} }
else else
g_extern.console.screen.viewports.custom_vp.height -= 1; custom->height -= 1;
if (driver.video_poke->apply_state_changes) if (driver.video_poke->apply_state_changes)
driver.video_poke->apply_state_changes(driver.video_data); driver.video_poke->apply_state_changes(driver.video_data);
break; break;
@ -1377,11 +1378,11 @@ static int rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action)
case RGUI_ACTION_DOWN: case RGUI_ACTION_DOWN:
if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT) if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT)
{ {
g_extern.console.screen.viewports.custom_vp.y += 1; custom->y += 1;
g_extern.console.screen.viewports.custom_vp.height -= 1; custom->height -= 1;
} }
else else
g_extern.console.screen.viewports.custom_vp.height += 1; custom->height += 1;
if (driver.video_poke->apply_state_changes) if (driver.video_poke->apply_state_changes)
driver.video_poke->apply_state_changes(driver.video_data); driver.video_poke->apply_state_changes(driver.video_data);
break; break;
@ -1389,11 +1390,11 @@ static int rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action)
case RGUI_ACTION_LEFT: case RGUI_ACTION_LEFT:
if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT) if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT)
{ {
g_extern.console.screen.viewports.custom_vp.x -= 1; custom->x -= 1;
g_extern.console.screen.viewports.custom_vp.width += 1; custom->width += 1;
} }
else else
g_extern.console.screen.viewports.custom_vp.width -= 1; custom->width -= 1;
if (driver.video_poke->apply_state_changes) if (driver.video_poke->apply_state_changes)
driver.video_poke->apply_state_changes(driver.video_data); driver.video_poke->apply_state_changes(driver.video_data);
break; break;
@ -1401,11 +1402,11 @@ static int rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action)
case RGUI_ACTION_RIGHT: case RGUI_ACTION_RIGHT:
if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT) if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT)
{ {
g_extern.console.screen.viewports.custom_vp.x += 1; custom->x += 1;
g_extern.console.screen.viewports.custom_vp.width -= 1; custom->width -= 1;
} }
else else
g_extern.console.screen.viewports.custom_vp.width += 1; custom->width += 1;
if (driver.video_poke->apply_state_changes) if (driver.video_poke->apply_state_changes)
driver.video_poke->apply_state_changes(driver.video_data); driver.video_poke->apply_state_changes(driver.video_data);
break; break;
@ -1413,28 +1414,30 @@ static int rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action)
case RGUI_ACTION_CANCEL: case RGUI_ACTION_CANCEL:
rgui_list_pop(rgui->menu_stack, &rgui->selection_ptr); rgui_list_pop(rgui->menu_stack, &rgui->selection_ptr);
if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT_2) if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT_2)
rgui_list_push(rgui->menu_stack, "", RGUI_SETTINGS_CUSTOM_VIEWPORT, 0); rgui_list_push(rgui->menu_stack, "", RGUI_SETTINGS_CUSTOM_VIEWPORT,
rgui->selection_ptr);
break; break;
case RGUI_ACTION_OK: case RGUI_ACTION_OK:
rgui_list_pop(rgui->menu_stack, &rgui->selection_ptr); rgui_list_pop(rgui->menu_stack, &rgui->selection_ptr);
if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT) if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT)
rgui_list_push(rgui->menu_stack, "", RGUI_SETTINGS_CUSTOM_VIEWPORT_2, 0); rgui_list_push(rgui->menu_stack, "", RGUI_SETTINGS_CUSTOM_VIEWPORT_2,
rgui->selection_ptr);
break; break;
case RGUI_ACTION_START: case RGUI_ACTION_START:
#ifdef GEKKO #ifdef GEKKO
if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT) if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT)
{ {
g_extern.console.screen.viewports.custom_vp.width += g_extern.console.screen.viewports.custom_vp.x; custom->width += custom->x;
g_extern.console.screen.viewports.custom_vp.height += g_extern.console.screen.viewports.custom_vp.y; custom->height += custom->y;
g_extern.console.screen.viewports.custom_vp.x = 0; custom->x = 0;
g_extern.console.screen.viewports.custom_vp.y = 0; custom->y = 0;
} }
else else
{ {
g_extern.console.screen.viewports.custom_vp.width = win_width - g_extern.console.screen.viewports.custom_vp.x; custom->width = win_width - custom->x;
g_extern.console.screen.viewports.custom_vp.height = win_height - g_extern.console.screen.viewports.custom_vp.y; custom->height = win_height - custom->y;
} }
#endif #endif
if (driver.video_poke->apply_state_changes) if (driver.video_poke->apply_state_changes)
@ -1457,10 +1460,16 @@ static int rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action)
render_text(rgui); render_text(rgui);
const char *base_msg = NULL;
if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT) if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT)
render_messagebox(rgui, "Set Upper-Left Corner"); base_msg = "Set Upper-Left Corner";
else if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT_2) else if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT_2)
render_messagebox(rgui, "Set Bottom-Right Corner"); base_msg = "Set Bottom-Right Corner";
char msg[64];
snprintf(msg, sizeof(msg), "%s (%d, %d : %4ux%4u)",
base_msg, custom->x, custom->y, custom->width, custom->height);
render_messagebox(rgui, msg);
return 0; return 0;
} }
@ -1541,16 +1550,20 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
else if (type == RGUI_SETTINGS_CUSTOM_VIEWPORT && action == RGUI_ACTION_OK) else if (type == RGUI_SETTINGS_CUSTOM_VIEWPORT && action == RGUI_ACTION_OK)
{ {
rgui_list_push(rgui->menu_stack, "", type, rgui->selection_ptr); rgui_list_push(rgui->menu_stack, "", type, rgui->selection_ptr);
g_settings.video.aspect_ratio_idx = ASPECT_RATIO_CUSTOM;
// Start with something sane.
rarch_viewport_t *custom = &g_extern.console.screen.viewports.custom_vp;
driver.video->viewport_info(driver.video_data, custom);
g_settings.video.aspect_ratio_idx = ASPECT_RATIO_CUSTOM;
if (driver.video_poke->set_aspect_ratio) if (driver.video_poke->set_aspect_ratio)
driver.video_poke->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx); driver.video_poke->set_aspect_ratio(driver.video_data,
g_settings.video.aspect_ratio_idx);
} }
else else
{ {
int ret = rgui_settings_toggle_setting(rgui, type, action, menu_type); int ret = rgui_settings_toggle_setting(rgui, type, action, menu_type);
if (ret)
if (ret != 0)
return ret; return ret;
} }
break; break;

View File

@ -165,31 +165,34 @@ void gfx_scale_integer(struct rarch_viewport *vp, unsigned width, unsigned heigh
} }
struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = {
{ "4:3", 1.3333f },
{ "16:9", 1.7778f },
{ "16:10", 1.6f },
{ "16:15", 16.0f / 15.0f },
#ifdef RARCH_CONSOLE
{ "1:1", 1.0f }, { "1:1", 1.0f },
{ "2:1", 2.0f }, { "2:1", 2.0f },
{ "3:2", 1.5f }, { "3:2", 1.5f },
{ "3:4", 0.75f }, { "3:4", 0.75f },
{ "4:1", 4.0f }, { "4:1", 4.0f },
{ "4:3", 1.3333f },
{ "4:4", 1.0f }, { "4:4", 1.0f },
{ "5:4", 1.25f }, { "5:4", 1.25f },
{ "6:5", 1.2f }, { "6:5", 1.2f },
{ "7:9", 0.7777f }, { "7:9", 0.7777f },
{ "8:3", 2.6666f }, { "8:3", 2.6666f },
{ "8:7", 1.1428f }, { "8:7", 1.1428f },
{ "16:9", 1.7778f },
{ "16:10", 1.6f },
{ "16:15", 16.0f / 15.0f },
{ "19:12", 1.5833f }, { "19:12", 1.5833f },
{ "19:14", 1.3571f }, { "19:14", 1.3571f },
{ "30:17", 1.7647f }, { "30:17", 1.7647f },
{ "32:9", 3.5555f }, { "32:9", 3.5555f },
{ "Auto", 1.0f }, #endif
{ "Core Provided", 1.0f }, { "Config", 0.0f },
{ "Square pixel", 1.0f },
{ "Core provided", 1.0f },
{ "Custom", 0.0f } { "Custom", 0.0f }
}; };
char rotation_lut[ASPECT_RATIO_END][32] = char rotation_lut[4][32] =
{ {
"Normal", "Normal",
"Vertical", "Vertical",
@ -197,29 +200,27 @@ char rotation_lut[ASPECT_RATIO_END][32] =
"Flipped Rotated" "Flipped Rotated"
}; };
void gfx_set_auto_viewport(unsigned width, unsigned height) void gfx_set_square_pixel_viewport(unsigned width, unsigned height)
{ {
if (width == 0 || height == 0) if (width == 0 || height == 0)
return; return;
unsigned aspect_x, aspect_y, len, highest, i; unsigned len = min(width, height);
unsigned highest = 1;
len = width < height ? width : height; for (unsigned i = 1; i < len; i++)
highest = 1;
for (i = 1; i < len; i++)
{ {
if ((width % i) == 0 && (height % i) == 0) if ((width % i) == 0 && (height % i) == 0)
highest = i; highest = i;
} }
aspect_x = width / highest; unsigned aspect_x = width / highest;
aspect_y = height / highest; unsigned aspect_y = height / highest;
snprintf(aspectratio_lut[ASPECT_RATIO_AUTO].name, snprintf(aspectratio_lut[ASPECT_RATIO_SQUARE].name,
sizeof(aspectratio_lut[ASPECT_RATIO_AUTO].name), sizeof(aspectratio_lut[ASPECT_RATIO_SQUARE].name),
"%d:%d (Auto)", aspect_x, aspect_y); "%u:%u (1:1 PAR)", aspect_x, aspect_y);
aspectratio_lut[ASPECT_RATIO_AUTO].value = (float)aspect_x / aspect_y; aspectratio_lut[ASPECT_RATIO_SQUARE].value = (float)aspect_x / aspect_y;
} }
void gfx_set_core_viewport(void) void gfx_set_core_viewport(void)
@ -227,10 +228,26 @@ void gfx_set_core_viewport(void)
if (!g_extern.main_is_init) if (!g_extern.main_is_init)
return; return;
// fallback to 1:1 pixel ratio if none provided const struct retro_game_geometry *geom = &g_extern.system.av_info.geometry;
if (g_extern.system.av_info.geometry.aspect_ratio == 0.0)
aspectratio_lut[ASPECT_RATIO_CORE].value = (float)g_extern.system.av_info.geometry.base_width / g_extern.system.av_info.geometry.base_height; // Fallback to 1:1 pixel ratio if none provided
if (geom->aspect_ratio > 0.0f)
aspectratio_lut[ASPECT_RATIO_CORE].value = geom->aspect_ratio;
else else
aspectratio_lut[ASPECT_RATIO_CORE].value = g_extern.system.av_info.geometry.aspect_ratio; aspectratio_lut[ASPECT_RATIO_CORE].value = (float)geom->base_width / geom->base_height;
}
void gfx_set_config_viewport(void)
{
if (g_settings.video.aspect_ratio < 0.0f)
{
const struct retro_game_geometry *geom = &g_extern.system.av_info.geometry;
if (geom->aspect_ratio > 0.0f && g_settings.video.aspect_ratio_auto)
aspectratio_lut[ASPECT_RATIO_CONFIG].value = geom->aspect_ratio;
else
aspectratio_lut[ASPECT_RATIO_CONFIG].value = (float)geom->base_width / geom->base_height; // 1:1 PAR.
}
else
aspectratio_lut[ASPECT_RATIO_CONFIG].value = g_settings.video.aspect_ratio;
} }

View File

@ -57,30 +57,33 @@ typedef struct
enum aspect_ratio enum aspect_ratio
{ {
ASPECT_RATIO_1_1 = 0, ASPECT_RATIO_4_3 = 0,
ASPECT_RATIO_16_9,
ASPECT_RATIO_16_10,
ASPECT_RATIO_16_15,
#ifdef RARCH_CONSOLE // None of these aspect ratios make any sense.
ASPECT_RATIO_1_1,
ASPECT_RATIO_2_1, ASPECT_RATIO_2_1,
ASPECT_RATIO_3_2, ASPECT_RATIO_3_2,
ASPECT_RATIO_3_4, ASPECT_RATIO_3_4,
ASPECT_RATIO_4_1, ASPECT_RATIO_4_1,
ASPECT_RATIO_4_3,
ASPECT_RATIO_4_4, ASPECT_RATIO_4_4,
ASPECT_RATIO_5_4, ASPECT_RATIO_5_4,
ASPECT_RATIO_6_5, ASPECT_RATIO_6_5,
ASPECT_RATIO_7_9, ASPECT_RATIO_7_9,
ASPECT_RATIO_8_3, ASPECT_RATIO_8_3,
ASPECT_RATIO_8_7, ASPECT_RATIO_8_7,
ASPECT_RATIO_16_9,
ASPECT_RATIO_16_10,
ASPECT_RATIO_16_15,
ASPECT_RATIO_19_12, ASPECT_RATIO_19_12,
ASPECT_RATIO_19_14, ASPECT_RATIO_19_14,
ASPECT_RATIO_30_17, ASPECT_RATIO_30_17,
ASPECT_RATIO_32_9, ASPECT_RATIO_32_9,
ASPECT_RATIO_AUTO, #endif
ASPECT_RATIO_CONFIG,
ASPECT_RATIO_SQUARE,
ASPECT_RATIO_CORE, ASPECT_RATIO_CORE,
ASPECT_RATIO_CUSTOM, ASPECT_RATIO_CUSTOM,
ASPECT_RATIO_END, ASPECT_RATIO_END
}; };
#define LAST_ASPECT_RATIO ASPECT_RATIO_CUSTOM #define LAST_ASPECT_RATIO ASPECT_RATIO_CUSTOM
@ -96,7 +99,7 @@ enum rotation
#define LAST_ORIENTATION (ORIENTATION_END - 1) #define LAST_ORIENTATION (ORIENTATION_END - 1)
extern char rotation_lut[ASPECT_RATIO_END][32]; extern char rotation_lut[4][32];
/* ABGR color format defines */ /* ABGR color format defines */
@ -120,8 +123,9 @@ struct aspect_ratio_elem
extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END]; extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END];
extern void gfx_set_auto_viewport(unsigned width, unsigned height); void gfx_set_square_pixel_viewport(unsigned width, unsigned height);
extern void gfx_set_core_viewport(void); void gfx_set_core_viewport(void);
void gfx_set_config_viewport(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -702,7 +702,7 @@ void gl_set_viewport(void *data, unsigned width, unsigned height, bool force_ful
{ {
gl_t *gl = (gl_t*)data; gl_t *gl = (gl_t*)data;
unsigned x = 0, y = 0; int x = 0, y = 0;
struct gl_ortho ortho = {0, 1, 0, 1, -1, 1}; struct gl_ortho ortho = {0, 1, 0, 1, -1, 1};
float device_aspect = 0.0f; float device_aspect = 0.0f;
@ -725,10 +725,14 @@ void gl_set_viewport(void *data, unsigned width, unsigned height, bool force_ful
#if defined(HAVE_RGUI) || defined(HAVE_RMENU) #if defined(HAVE_RGUI) || defined(HAVE_RMENU)
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
x = g_extern.console.screen.viewports.custom_vp.x; const struct rarch_viewport *custom =
y = g_extern.console.screen.viewports.custom_vp.y; &g_extern.console.screen.viewports.custom_vp;
width = g_extern.console.screen.viewports.custom_vp.width;
height = g_extern.console.screen.viewports.custom_vp.height; // GL has bottom-left origin viewport.
x = custom->x;
y = gl->win_height - custom->y - custom->height;
width = custom->width;
height = custom->height;
} }
else else
#endif #endif
@ -2242,34 +2246,6 @@ static void gl_get_overlay_interface(void *data, const video_overlay_interface_t
} }
#endif #endif
static void gl_set_filtering(void *data, unsigned index, bool smooth)
{
gl_t *gl = (gl_t*)data;
GLuint filter = smooth ? GL_LINEAR : GL_NEAREST;
if (index == 1)
{
gl->tex_filter = filter;
// Apply to all PREV textures.
for (unsigned i = 0; i < TEXTURES; i++)
{
glBindTexture(GL_TEXTURE_2D, gl->texture[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
}
}
#ifdef HAVE_FBO
else if (index >= 2 && gl->fbo_inited)
{
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[index - 2]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
}
#endif
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
}
#ifdef HAVE_FBO #ifdef HAVE_FBO
static uintptr_t gl_get_current_framebuffer(void *data) static uintptr_t gl_get_current_framebuffer(void *data)
{ {
@ -2284,19 +2260,30 @@ static retro_proc_address_t gl_get_proc_address(void *data, const char *sym)
} }
#endif #endif
static void gl_set_aspect_ratio(void *data, unsigned aspectratio_index) static void gl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
{ {
gl_t *gl = (gl_t*)data; gl_t *gl = (gl_t*)data;
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_AUTO) switch (aspect_ratio_idx)
gfx_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); {
else if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CORE) case ASPECT_RATIO_SQUARE:
gfx_set_core_viewport(); gfx_set_square_pixel_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height);
break;
g_extern.system.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value; case ASPECT_RATIO_CORE:
g_settings.video.force_aspect = false; gfx_set_core_viewport();
break;
case ASPECT_RATIO_CONFIG:
gfx_set_config_viewport();
break;
default:
break;
}
g_extern.system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value;
gl->keep_aspect = true; gl->keep_aspect = true;
gl->should_resize = true; gl->should_resize = true;
} }
@ -2375,7 +2362,7 @@ static void gl_show_mouse(void *data, bool state)
} }
static const video_poke_interface_t gl_poke_interface = { static const video_poke_interface_t gl_poke_interface = {
gl_set_filtering, NULL,
#ifdef HAVE_FBO #ifdef HAVE_FBO
gl_get_current_framebuffer, gl_get_current_framebuffer,
gl_get_proc_address, gl_get_proc_address,

View File

@ -281,17 +281,18 @@ const char *gx_get_video_mode(void)
return format; return format;
} }
static void gx_set_aspect_ratio(void *data, unsigned aspectratio_idx) static void gx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
{ {
gx_video_t *gx = (gx_video_t*)driver.video_data; gx_video_t *gx = (gx_video_t*)driver.video_data;
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_AUTO) if (aspect_ratio_idx == ASPECT_RATIO_SQUARE)
gfx_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); gfx_set_square_pixel_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height);
else if(g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CORE) else if (aspect_ratio_idx == ASPECT_RATIO_CORE)
gfx_set_core_viewport(); gfx_set_core_viewport();
else if (aspect_ratio_idx == ASPECT_RATIO_CONFIG)
gfx_set_config_viewport();
g_extern.system.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value; g_extern.system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value;
g_settings.video.force_aspect = false;
gx->keep_aspect = true; gx->keep_aspect = true;
gx->should_resize = true; gx->should_resize = true;
} }

View File

@ -170,6 +170,7 @@ void config_set_defaults(void)
g_settings.video.crop_overscan = crop_overscan; g_settings.video.crop_overscan = crop_overscan;
g_settings.video.aspect_ratio = aspect_ratio; g_settings.video.aspect_ratio = aspect_ratio;
g_settings.video.aspect_ratio_auto = aspect_ratio_auto; // Let implementation decide if automatic, or 1:1 PAR. g_settings.video.aspect_ratio_auto = aspect_ratio_auto; // Let implementation decide if automatic, or 1:1 PAR.
g_settings.video.aspect_ratio_idx = aspect_ratio_idx;
g_settings.video.shader_enable = shader_enable; g_settings.video.shader_enable = shader_enable;
g_settings.video.allow_rotate = allow_rotate; g_settings.video.allow_rotate = allow_rotate;
@ -265,7 +266,6 @@ void config_set_defaults(void)
strlcpy(g_extern.menu_texture_path, default_paths.menu_border_file, sizeof(g_extern.menu_texture_path)); strlcpy(g_extern.menu_texture_path, default_paths.menu_border_file, sizeof(g_extern.menu_texture_path));
#endif #endif
g_settings.video.aspect_ratio_idx = aspect_ratio_idx;
g_extern.state_slot = 0; g_extern.state_slot = 0;
g_extern.audio_data.mute = 0; g_extern.audio_data.mute = 0;
g_extern.verbose = true; g_extern.verbose = true;
@ -452,7 +452,6 @@ bool config_load_file(const char *path)
/* TODO - will be refactored later to make it more clean - it's more /* TODO - will be refactored later to make it more clean - it's more
* important that it works for consoles right now */ * important that it works for consoles right now */
CONFIG_GET_INT(video.aspect_ratio_idx, "aspect_ratio_index"); CONFIG_GET_INT(video.aspect_ratio_idx, "aspect_ratio_index");
CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio");
for (unsigned i = 0; i < MAX_PLAYERS; i++) for (unsigned i = 0; i < MAX_PLAYERS; i++)
{ {

View File

@ -1069,18 +1069,19 @@ static bool xdk_d3d_focus(void *data)
return gfx_ctx_window_has_focus(); return gfx_ctx_window_has_focus();
} }
static void xdk_d3d_set_aspect_ratio(void *data, unsigned aspectratio_index) static void xdk_d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
{ {
(void)data; (void)data;
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_AUTO) if (aspect_ratio_idx == ASPECT_RATIO_SQUARE)
gfx_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); gfx_set_square_pixel_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height);
else if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CORE) else if (aspect_ratio_idx == ASPECT_RATIO_CORE)
gfx_set_core_viewport(); gfx_set_core_viewport();
else if (aspect_ratio_idx == ASPECT_RATIO_CONFIG)
gfx_set_config_viewport();
g_settings.video.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value; g_settings.video.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value;
g_settings.video.force_aspect = false;
d3d->should_resize = true; d3d->should_resize = true;
} }