mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 09:35:21 +00:00
Abstract away aspect ratio handling.
This commit is contained in:
parent
254e711e2d
commit
2674a67cdd
@ -630,6 +630,7 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = {
|
||||
gfx_ctx_swap_interval,
|
||||
gfx_ctx_set_video_mode,
|
||||
gfx_ctx_get_video_size,
|
||||
NULL,
|
||||
gfx_ctx_update_window_title,
|
||||
gfx_ctx_check_window,
|
||||
gfx_ctx_set_resize,
|
||||
|
@ -422,6 +422,7 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = {
|
||||
gfx_ctx_set_swap_interval,
|
||||
gfx_ctx_set_video_mode,
|
||||
gfx_ctx_get_video_size,
|
||||
NULL,
|
||||
gfx_ctx_update_window_title,
|
||||
gfx_ctx_check_window,
|
||||
gfx_ctx_set_resize,
|
||||
|
@ -304,6 +304,7 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl = {
|
||||
gfx_ctx_swap_interval,
|
||||
gfx_ctx_set_video_mode,
|
||||
gfx_ctx_get_video_size,
|
||||
NULL,
|
||||
gfx_ctx_update_window_title,
|
||||
gfx_ctx_check_window,
|
||||
gfx_ctx_set_resize,
|
||||
|
@ -270,6 +270,15 @@ static bool gfx_ctx_bind_api(enum gfx_ctx_api api)
|
||||
}
|
||||
}
|
||||
|
||||
static float gfx_ctx_translate_aspect(unsigned width, unsigned height)
|
||||
{
|
||||
// check for SD televisions: they should always be 4:3.
|
||||
if ((width == 640 || width == 720) && (height == 480 || height == 576))
|
||||
return 4.0f / 3.0f;
|
||||
else
|
||||
return (float)width / height;
|
||||
}
|
||||
|
||||
const gfx_ctx_driver_t gfx_ctx_videocore = {
|
||||
gfx_ctx_init,
|
||||
gfx_ctx_destroy,
|
||||
@ -277,6 +286,7 @@ const gfx_ctx_driver_t gfx_ctx_videocore = {
|
||||
gfx_ctx_swap_interval,
|
||||
gfx_ctx_set_video_mode,
|
||||
gfx_ctx_get_video_size,
|
||||
gfx_ctx_translate_aspect,
|
||||
gfx_ctx_update_window_title,
|
||||
gfx_ctx_check_window,
|
||||
gfx_ctx_set_resize,
|
||||
|
@ -469,6 +469,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = {
|
||||
gfx_ctx_swap_interval,
|
||||
gfx_ctx_set_video_mode,
|
||||
gfx_ctx_get_video_size,
|
||||
NULL,
|
||||
gfx_ctx_update_window_title,
|
||||
gfx_ctx_check_window,
|
||||
gfx_ctx_set_resize,
|
||||
|
@ -55,6 +55,12 @@ typedef struct gfx_ctx_driver
|
||||
// If not initialized yet, it returns current screen size.
|
||||
void (*get_video_size)(unsigned*, unsigned*);
|
||||
|
||||
// Translates a window size to an aspect ratio.
|
||||
// In most cases this will be just width / height, but
|
||||
// some contexts will better know which actual aspect ratio is used.
|
||||
// This can be NULL to assume the default behavior.
|
||||
float (*translate_aspect)(unsigned, unsigned);
|
||||
|
||||
// Asks driver to update window title (FPS, etc).
|
||||
void (*update_window_title)(bool);
|
||||
|
||||
|
9
gfx/gl.c
9
gfx/gl.c
@ -609,11 +609,12 @@ void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full,
|
||||
if (gl->keep_aspect && !force_full)
|
||||
{
|
||||
float desired_aspect = g_settings.video.aspect_ratio;
|
||||
float device_aspect = (float)width / height;
|
||||
|
||||
// check for SD televisions: they should always be 4:3
|
||||
if ((width == 640 || width == 720) && (height == 480 || height == 576))
|
||||
device_aspect = 4.0f / 3.0f;
|
||||
float device_aspect;
|
||||
if (gl->driver->translate_aspect)
|
||||
device_aspect = gl->driver->translate_aspect(width, height);
|
||||
else
|
||||
device_aspect = (float)width / height;
|
||||
|
||||
float delta;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user