Port remaining PCem OpenGL renderer features

This commit is contained in:
Cacodemon345
2025-08-27 02:24:59 +06:00
parent e42ce145b1
commit 18cdab52ac
7 changed files with 337 additions and 12 deletions

View File

@@ -49,6 +49,73 @@ integer_scale(double *d, double *g)
}
}
void
standalone_scale(QRect &destination, int width, int height, QRect source, int scalemode)
{
double dx;
double dy;
double dw;
double dh;
double gsr;
double hw = width;
double hh = height;
double gw = source.width();
double gh = source.height();
double hsr = hw / hh;
double r43 = 4.0 / 3.0;
switch (scalemode) {
case FULLSCR_SCALE_INT:
case FULLSCR_SCALE_INT43:
gsr = gw / gh;
if (scalemode == FULLSCR_SCALE_INT43) {
gh = gw / r43;
gsr = r43;
}
if (gsr <= hsr) {
dw = hh * gsr;
dh = hh;
} else {
dw = hw;
dh = hw / gsr;
}
integer_scale(&dw, &gw);
integer_scale(&dh, &gh);
dx = (hw - dw) / 2.0;
dy = (hh - dh) / 2.0;
destination.setRect((int) dx, (int) dy, (int) dw, (int) dh);
break;
case FULLSCR_SCALE_43:
case FULLSCR_SCALE_KEEPRATIO:
if (scalemode == FULLSCR_SCALE_43)
gsr = r43;
else
gsr = gw / gh;
if (gsr <= hsr) {
dw = hh * gsr;
dh = hh;
} else {
dw = hw;
dh = hw / gsr;
}
dx = (hw - dw) / 2.0;
dy = (hh - dh) / 2.0;
destination.setRect((int) dx, (int) dy, (int) dw, (int) dh);
break;
case FULLSCR_SCALE_FULL:
default:
destination.setRect(0, 0, (int) hw, (int) hh);
break;
}
}
void
RendererCommon::onResize(int width, int height)
{