Integer scale is now actually integer scale (but might still be blurred by the host hardware if using the SDL (Hardware) renderer, so use SDL (Software) if you don't want the blur).
This commit is contained in:
@@ -12,13 +12,13 @@
|
|||||||
* we will not use that, but, instead, use a new window which
|
* we will not use that, but, instead, use a new window which
|
||||||
* coverrs the entire desktop.
|
* coverrs the entire desktop.
|
||||||
*
|
*
|
||||||
* Version: @(#)win_sdl.c 1.0.10 2019/12/06
|
* Version: @(#)win_sdl.c 1.0.11 2020/01/22
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Michael Dr<44>ing, <michael@drueing.de>
|
* Michael Dr<44>ing, <michael@drueing.de>
|
||||||
*
|
*
|
||||||
* Copyright 2018,2019 Fred N. van Kempen.
|
* Copyright 2018-2020 Fred N. van Kempen.
|
||||||
* Copyright 2018,2019 Michael Dr<44>ing.
|
* Copyright 2018-2020 Michael Dr<44>ing.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with
|
* Redistribution and use in source and binary forms, with
|
||||||
* or without modification, are permitted provided that the
|
* or without modification, are permitted provided that the
|
||||||
@@ -108,10 +108,31 @@ sdl_log(const char *fmt, ...)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
sdl_integer_scale(double *d, double *g)
|
||||||
|
{
|
||||||
|
double ratio;
|
||||||
|
|
||||||
|
if (*d > *g) {
|
||||||
|
ratio = floor(*d / *g);
|
||||||
|
*d = *g * ratio;
|
||||||
|
} else {
|
||||||
|
ratio = ceil(*d / *g);
|
||||||
|
*d = *g / ratio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sdl_stretch(int *w, int *h, int *x, int *y)
|
sdl_stretch(int *w, int *h, int *x, int *y)
|
||||||
{
|
{
|
||||||
double dw, dh, dx, dy, temp, temp2, ratio_w, ratio_h, gsr, hsr;
|
double hw, gw, hh, gh, dx, dy, dw, dh, gsr, hsr;
|
||||||
|
|
||||||
|
hw = (double) sdl_w;
|
||||||
|
hh = (double) sdl_h;
|
||||||
|
gw = (double) *w;
|
||||||
|
gh = (double) *h;
|
||||||
|
hsr = hw / hh;
|
||||||
|
|
||||||
switch (video_fullscreen_scale) {
|
switch (video_fullscreen_scale) {
|
||||||
case FULLSCR_SCALE_FULL:
|
case FULLSCR_SCALE_FULL:
|
||||||
@@ -122,44 +143,37 @@ sdl_stretch(int *w, int *h, int *x, int *y)
|
|||||||
break;
|
break;
|
||||||
case FULLSCR_SCALE_43:
|
case FULLSCR_SCALE_43:
|
||||||
case FULLSCR_SCALE_KEEPRATIO:
|
case FULLSCR_SCALE_KEEPRATIO:
|
||||||
dw = (double) sdl_w;
|
|
||||||
dh = (double) sdl_h;
|
|
||||||
hsr = dw / dh;
|
|
||||||
if (video_fullscreen_scale == FULLSCR_SCALE_43)
|
if (video_fullscreen_scale == FULLSCR_SCALE_43)
|
||||||
gsr = 4.0 / 3.0;
|
gsr = 4.0 / 3.0;
|
||||||
else
|
else
|
||||||
gsr = ((double) *w) / ((double) *h);
|
gsr = gw / gh;
|
||||||
if (gsr <= hsr) {
|
if (gsr <= hsr) {
|
||||||
temp = dh * gsr;
|
dw = hh * gsr;
|
||||||
dx = (dw - temp) / 2.0;
|
dh = hh;
|
||||||
dw = temp;
|
|
||||||
*w = (int) dw;
|
|
||||||
*h = (int) dh;
|
|
||||||
*x = (int) dx;
|
|
||||||
*y = 0;
|
|
||||||
} else {
|
} else {
|
||||||
temp = dw / gsr;
|
dw = hw;
|
||||||
dy = (dh - temp) / 2.0;
|
dh = hw / gsr;
|
||||||
dh = temp;
|
|
||||||
*w = (int) dw;
|
|
||||||
*h = (int) dh;
|
|
||||||
*x = 0;
|
|
||||||
*y = (int) dy;
|
|
||||||
}
|
}
|
||||||
|
dx = (hw - dw) / 2.0;
|
||||||
|
dy = (hh - dh) / 2.0;
|
||||||
|
*w = (int) hw;
|
||||||
|
*h = (int) hh;
|
||||||
|
*x = (int) dx;
|
||||||
|
*y = (int) dy;
|
||||||
break;
|
break;
|
||||||
case FULLSCR_SCALE_INT:
|
case FULLSCR_SCALE_INT:
|
||||||
dw = (double) sdl_w;
|
gsr = gw / gh;
|
||||||
dh = (double) sdl_h;
|
if (gsr <= hsr) {
|
||||||
temp = ((double) *w);
|
dw = hh * gsr;
|
||||||
temp2 = ((double) *h);
|
dh = hh;
|
||||||
ratio_w = dw / ((double) *w);
|
} else {
|
||||||
ratio_h = dh / ((double) *h);
|
dw = hw;
|
||||||
if (ratio_h < ratio_w)
|
dh = hw / gsr;
|
||||||
ratio_w = ratio_h;
|
}
|
||||||
dx = (dw / 2.0) - ((temp * ratio_w) / 2.0);
|
sdl_integer_scale(&dw, &gw);
|
||||||
dy = (dh / 2.0) - ((temp2 * ratio_h) / 2.0);
|
sdl_integer_scale(&dh, &gh);
|
||||||
dw -= (dx * 2.0);
|
dx = (hw - dw) / 2.0;
|
||||||
dh -= (dy * 2.0);
|
dy = (hh - dh) / 2.0;
|
||||||
*w = (int) dw;
|
*w = (int) dw;
|
||||||
*h = (int) dh;
|
*h = (int) dh;
|
||||||
*x = (int) dx;
|
*x = (int) dx;
|
||||||
|
|||||||
Reference in New Issue
Block a user