mirror of
https://github.com/86Box/86Box.git
synced 2026-02-23 01:48:21 -07:00
Port remaining PCem OpenGL renderer features
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user