Port remaining PCem OpenGL renderer features
This commit is contained in:
@@ -234,6 +234,9 @@ int portable_mode = 0; /* We are runn
|
|||||||
int monitor_edid = 0; /* (C) Which EDID to use. 0=default, 1=custom. */
|
int monitor_edid = 0; /* (C) Which EDID to use. 0=default, 1=custom. */
|
||||||
char monitor_edid_path[1024] = { 0 }; /* (C) Path to custom EDID */
|
char monitor_edid_path[1024] = { 0 }; /* (C) Path to custom EDID */
|
||||||
|
|
||||||
|
double video_gl_input_scale = 1.0; /* (C) OpenGL 3.x input scale */
|
||||||
|
int video_gl_input_scale_mode = FULLSCR_SCALE_FULL; /* (C) OpenGL 3.x input stretch mode */
|
||||||
|
|
||||||
// Accelerator key array
|
// Accelerator key array
|
||||||
struct accelKey acc_keys[NUM_ACCELS];
|
struct accelKey acc_keys[NUM_ACCELS];
|
||||||
|
|
||||||
|
|||||||
15
src/config.c
15
src/config.c
@@ -227,6 +227,9 @@ load_general(void)
|
|||||||
video_framerate = ini_section_get_int(cat, "video_gl_framerate", -1);
|
video_framerate = ini_section_get_int(cat, "video_gl_framerate", -1);
|
||||||
video_vsync = ini_section_get_int(cat, "video_gl_vsync", 0);
|
video_vsync = ini_section_get_int(cat, "video_gl_vsync", 0);
|
||||||
|
|
||||||
|
video_gl_input_scale = ini_section_get_double(cat, "video_gl_input_scale", 1.0);
|
||||||
|
video_gl_input_scale_mode = ini_section_get_int(cat, "video_gl_input_scale_mode", FULLSCR_SCALE_FULL);
|
||||||
|
|
||||||
window_remember = ini_section_get_int(cat, "window_remember", 0);
|
window_remember = ini_section_get_int(cat, "window_remember", 0);
|
||||||
if (window_remember) {
|
if (window_remember) {
|
||||||
p = ini_section_get_string(cat, "window_coordinates", NULL);
|
p = ini_section_get_string(cat, "window_coordinates", NULL);
|
||||||
@@ -2398,6 +2401,18 @@ save_general(void)
|
|||||||
else
|
else
|
||||||
ini_section_delete_var(cat, "do_auto_pause");
|
ini_section_delete_var(cat, "do_auto_pause");
|
||||||
|
|
||||||
|
if (video_gl_input_scale != 1.0) {
|
||||||
|
ini_section_set_double(cat, "video_gl_input_scale", video_gl_input_scale);
|
||||||
|
} else {
|
||||||
|
ini_section_delete_var(cat, "video_gl_input_scale");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (video_gl_input_scale_mode != FULLSCR_SCALE_FULL) {
|
||||||
|
ini_section_set_int(cat, "video_gl_input_scale_mode", video_gl_input_scale_mode);
|
||||||
|
} else {
|
||||||
|
ini_section_delete_var(cat, "video_gl_input_scale_mode");
|
||||||
|
}
|
||||||
|
|
||||||
if (force_constant_mouse)
|
if (force_constant_mouse)
|
||||||
ini_section_set_int(cat, "force_constant_mouse", force_constant_mouse);
|
ini_section_set_int(cat, "force_constant_mouse", force_constant_mouse);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ extern int force_43; /* (C) video */
|
|||||||
extern int video_filter_method; /* (C) video */
|
extern int video_filter_method; /* (C) video */
|
||||||
extern int video_vsync; /* (C) video */
|
extern int video_vsync; /* (C) video */
|
||||||
extern int video_framerate; /* (C) video */
|
extern int video_framerate; /* (C) video */
|
||||||
|
extern double video_gl_input_scale; /* (C) OpenGL 3.x input scale */
|
||||||
|
extern int video_gl_input_scale_mode; /* (C) OpenGL 3.x input stretch mode */
|
||||||
extern int gfxcard[GFXCARD_MAX]; /* (C) graphics/video card */
|
extern int gfxcard[GFXCARD_MAX]; /* (C) graphics/video card */
|
||||||
extern int bugger_enabled; /* (C) enable ISAbugger */
|
extern int bugger_enabled; /* (C) enable ISAbugger */
|
||||||
extern int novell_keycard_enabled; /* (C) enable Novell NetWare 2.x key card emulation. */
|
extern int novell_keycard_enabled; /* (C) enable Novell NetWare 2.x key card emulation. */
|
||||||
|
|||||||
@@ -530,6 +530,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
ui->stackedWidget->switchRenderer(newVidApi);
|
ui->stackedWidget->switchRenderer(newVidApi);
|
||||||
|
ui->menuOpenGL_input_scale->setEnabled(newVidApi == RendererStack::Renderer::OpenGL3);
|
||||||
|
ui->menuOpenGL_input_stretch_mode->setEnabled(newVidApi == RendererStack::Renderer::OpenGL3);
|
||||||
if (!show_second_monitors)
|
if (!show_second_monitors)
|
||||||
return;
|
return;
|
||||||
for (int i = 1; i < MONITORS_NUM; i++) {
|
for (int i = 1; i < MONITORS_NUM; i++) {
|
||||||
@@ -550,6 +552,41 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->action_0_5x_2->setChecked(video_gl_input_scale < 1.0);
|
||||||
|
ui->action_1x_2->setChecked(video_gl_input_scale >= 1.0 && video_gl_input_scale < 1.5);
|
||||||
|
ui->action1_5x_2->setChecked(video_gl_input_scale >= 1.5 && video_gl_input_scale < 2.0);
|
||||||
|
ui->action_2x_2->setChecked(video_gl_input_scale >= 2.0 && video_gl_input_scale < 3.0);
|
||||||
|
ui->action_3x_2->setChecked(video_gl_input_scale >= 3.0 && video_gl_input_scale < 4.0);
|
||||||
|
ui->action_4x_2->setChecked(video_gl_input_scale >= 4.0 && video_gl_input_scale < 5.0);
|
||||||
|
ui->action_5x_2->setChecked(video_gl_input_scale >= 5.0 && video_gl_input_scale < 6.0);
|
||||||
|
ui->action_6x_2->setChecked(video_gl_input_scale >= 6.0 && video_gl_input_scale < 7.0);
|
||||||
|
ui->action_7x_2->setChecked(video_gl_input_scale >= 7.0 && video_gl_input_scale < 8.0);
|
||||||
|
ui->action_8x_2->setChecked(video_gl_input_scale >= 8.0);
|
||||||
|
|
||||||
|
actGroup = new QActionGroup(this);
|
||||||
|
actGroup->addAction(ui->action_0_5x_2);
|
||||||
|
actGroup->addAction(ui->action_1x_2);
|
||||||
|
actGroup->addAction(ui->action1_5x_2);
|
||||||
|
actGroup->addAction(ui->action_2x_2);
|
||||||
|
actGroup->addAction(ui->action_3x_2);
|
||||||
|
actGroup->addAction(ui->action_4x_2);
|
||||||
|
actGroup->addAction(ui->action_5x_2);
|
||||||
|
actGroup->addAction(ui->action_6x_2);
|
||||||
|
actGroup->addAction(ui->action_7x_2);
|
||||||
|
actGroup->addAction(ui->action_8x_2);
|
||||||
|
connect(actGroup, &QActionGroup::triggered, this, [this](QAction* action) {
|
||||||
|
if (action == ui->action_0_5x_2) video_gl_input_scale = 0.5;
|
||||||
|
if (action == ui->action_1x_2) video_gl_input_scale = 1;
|
||||||
|
if (action == ui->action1_5x_2) video_gl_input_scale = 1.5;
|
||||||
|
if (action == ui->action_2x_2) video_gl_input_scale = 2;
|
||||||
|
if (action == ui->action_3x_2) video_gl_input_scale = 3;
|
||||||
|
if (action == ui->action_4x_2) video_gl_input_scale = 4;
|
||||||
|
if (action == ui->action_5x_2) video_gl_input_scale = 5;
|
||||||
|
if (action == ui->action_6x_2) video_gl_input_scale = 6;
|
||||||
|
if (action == ui->action_7x_2) video_gl_input_scale = 7;
|
||||||
|
if (action == ui->action_8x_2) video_gl_input_scale = 8;
|
||||||
|
});
|
||||||
|
|
||||||
switch (scale) {
|
switch (scale) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -633,6 +670,38 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
actGroup->addAction(ui->actionFullScreen_keepRatio);
|
actGroup->addAction(ui->actionFullScreen_keepRatio);
|
||||||
actGroup->addAction(ui->actionFullScreen_int);
|
actGroup->addAction(ui->actionFullScreen_int);
|
||||||
actGroup->addAction(ui->actionFullScreen_int43);
|
actGroup->addAction(ui->actionFullScreen_int43);
|
||||||
|
switch (video_gl_input_scale_mode) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
case FULLSCR_SCALE_FULL:
|
||||||
|
ui->action_Full_screen_stretch_gl->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FULLSCR_SCALE_43:
|
||||||
|
ui->action_4_3_gl->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FULLSCR_SCALE_KEEPRATIO:
|
||||||
|
ui->action_Square_pixels_keep_ratio_gl->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FULLSCR_SCALE_INT:
|
||||||
|
ui->action_Integer_scale_gl->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FULLSCR_SCALE_INT43:
|
||||||
|
ui->action4_3_Integer_scale_gl->setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
actGroup = new QActionGroup(this);
|
||||||
|
actGroup->addAction(ui->action_Full_screen_stretch_gl);
|
||||||
|
actGroup->addAction(ui->action_4_3_gl);
|
||||||
|
actGroup->addAction(ui->action_Square_pixels_keep_ratio_gl);
|
||||||
|
actGroup->addAction(ui->action_Integer_scale_gl);
|
||||||
|
actGroup->addAction(ui->action4_3_Integer_scale_gl);
|
||||||
|
connect(actGroup, &QActionGroup::triggered, this, [this](QAction* action) {
|
||||||
|
if (action == ui->action_Full_screen_stretch_gl) video_gl_input_scale_mode = FULLSCR_SCALE_FULL;
|
||||||
|
if (action == ui->action_4_3_gl) video_gl_input_scale_mode = FULLSCR_SCALE_43;
|
||||||
|
if (action == ui->action_Square_pixels_keep_ratio_gl) video_gl_input_scale_mode = FULLSCR_SCALE_KEEPRATIO;
|
||||||
|
if (action == ui->action_Integer_scale_gl) video_gl_input_scale_mode = FULLSCR_SCALE_INT;
|
||||||
|
if (action == ui->action4_3_Integer_scale_gl) video_gl_input_scale_mode = FULLSCR_SCALE_INT43;
|
||||||
|
});
|
||||||
switch (video_grayscale) {
|
switch (video_grayscale) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -1714,6 +1783,21 @@ MainWindow::on_actionInverted_VGA_monitor_triggered()
|
|||||||
video_toggle_option(ui->actionInverted_VGA_monitor, &invert_display);
|
video_toggle_option(ui->actionInverted_VGA_monitor, &invert_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_scaled_checkboxes_gl(Ui::MainWindow *ui, QAction *selected)
|
||||||
|
{
|
||||||
|
ui->action_0_5x_2->setChecked(ui->action_0_5x_2 == selected);
|
||||||
|
ui->action_1x_2->setChecked(ui->action_1x_2 == selected);
|
||||||
|
ui->action1_5x_2->setChecked(ui->action1_5x_2 == selected);
|
||||||
|
ui->action_2x_2->setChecked(ui->action_2x_2 == selected);
|
||||||
|
ui->action_3x_2->setChecked(ui->action_3x_2 == selected);
|
||||||
|
ui->action_4x_2->setChecked(ui->action_4x_2 == selected);
|
||||||
|
ui->action_5x_2->setChecked(ui->action_5x_2 == selected);
|
||||||
|
ui->action_6x_2->setChecked(ui->action_6x_2 == selected);
|
||||||
|
ui->action_7x_2->setChecked(ui->action_7x_2 == selected);
|
||||||
|
ui->action_8x_2->setChecked(ui->action_8x_2 == selected);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_scaled_checkboxes(Ui::MainWindow *ui, QAction *selected)
|
update_scaled_checkboxes(Ui::MainWindow *ui, QAction *selected)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -186,6 +186,31 @@
|
|||||||
<addaction name="menuVGA_screen_type"/>
|
<addaction name="menuVGA_screen_type"/>
|
||||||
<addaction name="menuGrayscale_conversion_type"/>
|
<addaction name="menuGrayscale_conversion_type"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuOpenGL_input_stretch_mode">
|
||||||
|
<property name="title">
|
||||||
|
<string>OpenGL input stretch mode</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="action_Full_screen_stretch_gl"/>
|
||||||
|
<addaction name="action_4_3_gl"/>
|
||||||
|
<addaction name="action_Square_pixels_keep_ratio_gl"/>
|
||||||
|
<addaction name="action_Integer_scale_gl"/>
|
||||||
|
<addaction name="action4_3_Integer_scale_gl"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuOpenGL_input_scale">
|
||||||
|
<property name="title">
|
||||||
|
<string>OpenGL input scale</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="action_0_5x_2"/>
|
||||||
|
<addaction name="action_1x_2"/>
|
||||||
|
<addaction name="action1_5x_2"/>
|
||||||
|
<addaction name="action_2x_2"/>
|
||||||
|
<addaction name="action_3x_2"/>
|
||||||
|
<addaction name="action_4x_2"/>
|
||||||
|
<addaction name="action_5x_2"/>
|
||||||
|
<addaction name="action_6x_2"/>
|
||||||
|
<addaction name="action_7x_2"/>
|
||||||
|
<addaction name="action_8x_2"/>
|
||||||
|
</widget>
|
||||||
<addaction name="actionHide_tool_bar"/>
|
<addaction name="actionHide_tool_bar"/>
|
||||||
<addaction name="actionHide_status_bar"/>
|
<addaction name="actionHide_status_bar"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
@@ -195,6 +220,8 @@
|
|||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="menuRenderer"/>
|
<addaction name="menuRenderer"/>
|
||||||
<addaction name="actionRenderer_options"/>
|
<addaction name="actionRenderer_options"/>
|
||||||
|
<addaction name="menuOpenGL_input_stretch_mode"/>
|
||||||
|
<addaction name="menuOpenGL_input_scale"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionSpecify_dimensions"/>
|
<addaction name="actionSpecify_dimensions"/>
|
||||||
<addaction name="actionForce_4_3_display_ratio"/>
|
<addaction name="actionForce_4_3_display_ratio"/>
|
||||||
@@ -894,6 +921,134 @@
|
|||||||
<string>&CGA composite settings...</string>
|
<string>&CGA composite settings...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="action_Full_screen_stretch_gl">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Full screen stretch</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_4_3_gl">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&4:3</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_Square_pixels_keep_ratio_gl">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Square pixels (keep ratio)</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_Integer_scale_gl">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Integer scale</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action4_3_Integer_scale_gl">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>4:&3 Integer scale</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_1x">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&1x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_0_5x_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&0.5x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_1x_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&1x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action1_5x_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>1.&5x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_2x_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&2x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_3x_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&3x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_4x_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&4x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_5x_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&5x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_6x_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&6x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_7x_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&7x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_8x_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&8x</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|||||||
@@ -1386,6 +1386,8 @@ OpenGLRenderer::getOptions(QWidget *parent)
|
|||||||
return new OpenGLShaderManagerDialog(parent);
|
return new OpenGLShaderManagerDialog(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void standalone_scale(QRect &destination, int width, int height, QRect source, int scalemode);
|
||||||
|
|
||||||
void
|
void
|
||||||
OpenGLRenderer::render()
|
OpenGLRenderer::render()
|
||||||
{
|
{
|
||||||
@@ -1428,19 +1430,16 @@ OpenGLRenderer::render()
|
|||||||
{
|
{
|
||||||
struct shader_pass *pass = &active_shader->scene;
|
struct shader_pass *pass = &active_shader->scene;
|
||||||
|
|
||||||
struct {
|
QRect rect;
|
||||||
uint32_t x;
|
rect.setX(0);
|
||||||
uint32_t y;
|
rect.setY(0);
|
||||||
uint32_t w;
|
rect.setWidth(source.width() * video_gl_input_scale);
|
||||||
uint32_t h;
|
rect.setHeight(source.height() * video_gl_input_scale);
|
||||||
} rect;
|
|
||||||
rect.x = 0;
|
|
||||||
rect.y = 0;
|
|
||||||
rect.w = source.width();
|
|
||||||
rect.h = source.height();
|
|
||||||
|
|
||||||
pass->state.input_size[0] = pass->state.output_size[0] = rect.w;
|
standalone_scale(rect, source.width(), source.height(), rect, video_gl_input_scale_mode);
|
||||||
pass->state.input_size[1] = pass->state.output_size[1] = rect.h;
|
|
||||||
|
pass->state.input_size[0] = pass->state.output_size[0] = rect.width();
|
||||||
|
pass->state.input_size[1] = pass->state.output_size[1] = rect.height();
|
||||||
|
|
||||||
pass->state.input_texture_size[0] = pass->state.output_texture_size[0] = next_pow2(pass->state.output_size[0]);
|
pass->state.input_texture_size[0] = pass->state.output_texture_size[0] = next_pow2(pass->state.output_size[0]);
|
||||||
pass->state.input_texture_size[1] = pass->state.output_texture_size[1] = next_pow2(pass->state.output_size[1]);
|
pass->state.input_texture_size[1] = pass->state.output_texture_size[1] = next_pow2(pass->state.output_size[1]);
|
||||||
|
|||||||
@@ -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
|
void
|
||||||
RendererCommon::onResize(int width, int height)
|
RendererCommon::onResize(int width, int height)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user