Create GFX_CTL_TRANSLATE_ASPECT

This commit is contained in:
twinaphex 2016-02-13 22:07:56 +01:00
parent f94e9c532e
commit ce41c5bbca
4 changed files with 23 additions and 10 deletions

View File

@ -647,12 +647,18 @@ static void d3d_calculate_rect(void *data,
bool force_full,
bool allow_rotate)
{
gfx_ctx_aspect_t aspect_data;
float device_aspect = (float)*width / *height;
d3d_video_t *d3d = (d3d_video_t*)data;
settings_t *settings = config_get_ptr();
video_driver_get_size(width, height);
gfx_ctx_translate_aspect(&device_aspect, *width, *height);
aspect_data.aspect = &device_aspect;
aspect_data.width = *width;
aspect_data.height = *height;
gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data);
*x = 0;
*y = 0;

View File

@ -848,6 +848,7 @@ static void gl_set_projection(gl_t *gl, struct gfx_ortho *ortho, bool allow_rota
static void gl_set_viewport(void *data, unsigned viewport_width,
unsigned viewport_height, bool force_full, bool allow_rotate)
{
gfx_ctx_aspect_t aspect_data;
unsigned width, height;
int x = 0, y = 0;
float device_aspect = (float)viewport_width / viewport_height;
@ -857,8 +858,11 @@ static void gl_set_viewport(void *data, unsigned viewport_width,
video_driver_get_size(&width, &height);
gfx_ctx_translate_aspect(&device_aspect,
viewport_width, viewport_height);
aspect_data.aspect = &device_aspect;
aspect_data.width = viewport_width;
aspect_data.height = viewport_height;
gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data);
if (settings->video.scale_integer && !force_full)
{

View File

@ -85,6 +85,7 @@ static INLINE bool vg_query_extension(const char *ext)
static void *vg_init(const video_info_t *video, const input_driver_t **input, void **input_data)
{
gfx_ctx_aspect_t aspect_data;
unsigned interval;
unsigned temp_width = 0, temp_height = 0;
VGfloat clearColor[4] = {0, 0, 0, 1};
@ -142,7 +143,11 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo
vg->mScreenAspect = (float)temp_width / temp_height;
gfx_ctx_translate_aspect(&vg->mScreenAspect, temp_width, temp_height);
aspect_data.aspect = &vg->mScreenAspect;
aspect_data.width = temp_width;
aspect_data.height = temp_height;
gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data);
vgSetfv(VG_CLEAR_COLOR, 4, clearColor);

View File

@ -73,7 +73,8 @@ enum gfx_ctx_ctl_state
GFX_CTL_FIND_PREV_DRIVER,
GFX_CTL_GET_VIDEO_OUTPUT_SIZE,
GFX_CTL_SWAP_INTERVAL,
GFX_CTL_PROC_ADDRESS_GET
GFX_CTL_PROC_ADDRESS_GET,
GFX_CTL_TRANSLATE_ASPECT
};
typedef void (*gfx_ctx_proc_t)(void);
@ -191,8 +192,8 @@ typedef struct gfx_ctx_metrics
typedef struct gfx_ctx_aspect
{
float *aspect;
unsigned *width;
unsigned *height;
unsigned width;
unsigned height;
} gfx_ctx_aspect_t;
typedef struct gfx_ctx_image
@ -255,9 +256,6 @@ const gfx_ctx_driver_t *gfx_ctx_init_first(void *data, const char *ident,
bool gfx_ctx_get_metrics(enum display_metric_types type, float *value);
void gfx_ctx_translate_aspect(float *aspect,
unsigned width, unsigned height);
bool gfx_ctx_set_video_mode(unsigned width, unsigned height,
bool fullscreen);