Skip to content

Commit

Permalink
RMG: implement OpenGL ES option
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Jun 30, 2024
1 parent ec60999 commit e17685f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Source/RMG/UserInterface/Dialog/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ void SettingsDialog::loadInterfaceEmulationSettings(void)
this->automaticFullscreenCheckbox->setChecked(CoreSettingsGetBoolValue(SettingsID::GUI_AutomaticFullscreen));
this->confirmDragDropCheckBox->setChecked(CoreSettingsGetBoolValue(SettingsID::GUI_ConfirmDragDrop));
this->statusBarMessageDurationSpinBox->setValue(CoreSettingsGetIntValue(SettingsID::GUI_StatusbarMessageDuration));
this->openglTypeComboBox->setCurrentIndex(CoreSettingsGetBoolValue(SettingsID::GUI_OpenGLES));
}

void SettingsDialog::loadInterfaceRomBrowserSettings(void)
Expand Down Expand Up @@ -645,6 +646,7 @@ void SettingsDialog::loadDefaultInterfaceEmulationSettings(void)
this->automaticFullscreenCheckbox->setChecked(CoreSettingsGetDefaultBoolValue(SettingsID::GUI_AutomaticFullscreen));
this->confirmDragDropCheckBox->setChecked(CoreSettingsGetDefaultBoolValue(SettingsID::GUI_ConfirmDragDrop));
this->statusBarMessageDurationSpinBox->setValue(CoreSettingsGetDefaultIntValue(SettingsID::GUI_StatusbarMessageDuration));
this->openglTypeComboBox->setCurrentIndex(CoreSettingsGetDefaultBoolValue(SettingsID::GUI_OpenGLES));
}

void SettingsDialog::loadDefaultInterfaceRomBrowserSettings(void)
Expand Down Expand Up @@ -874,6 +876,7 @@ void SettingsDialog::saveInterfaceEmulationSettings(void)
CoreSettingsSetValue(SettingsID::GUI_AutomaticFullscreen, this->automaticFullscreenCheckbox->isChecked());
CoreSettingsSetValue(SettingsID::GUI_ConfirmDragDrop, this->confirmDragDropCheckBox->isChecked());
CoreSettingsSetValue(SettingsID::GUI_StatusbarMessageDuration, this->statusBarMessageDurationSpinBox->value());
CoreSettingsSetValue(SettingsID::GUI_OpenGLES, this->openglTypeComboBox->currentIndex() == 1);
}

void SettingsDialog::saveInterfaceRomBrowserSettings(void)
Expand Down
25 changes: 25 additions & 0 deletions Source/RMG/UserInterface/Dialog/SettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,31 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>OpenGL Type</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="openglTypeComboBox">
<item>
<property name="text">
<string>OpenGL</string>
</property>
</item>
<item>
<property name="text">
<string>OpenGL ES</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
Expand Down
28 changes: 27 additions & 1 deletion Source/RMG/UserInterface/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,14 @@ void MainWindow::updateUI(bool inEmulation, bool isPaused)

if (this->ui_VidExtRenderMode == VidExtRenderMode::OpenGL)
{
this->ui_StatusBar_RenderModeLabel->setText("OpenGL");
if (QSurfaceFormat::defaultFormat().renderableType() == QSurfaceFormat::OpenGLES)
{
this->ui_StatusBar_RenderModeLabel->setText("OpenGL ES");
}
else
{
this->ui_StatusBar_RenderModeLabel->setText("OpenGL");
}
this->ui_Widgets->setCurrentWidget(this->ui_Widget_OpenGL->GetWidget());
}
else if (this->ui_VidExtRenderMode == VidExtRenderMode::Vulkan)
Expand Down Expand Up @@ -2114,6 +2121,25 @@ void MainWindow::on_VidExt_Init(VidExtRenderMode renderMode)
this->ui_VidExtRenderMode = renderMode;
this->ui_VidExtForceSetMode = true;

if (CoreSettingsGetBoolValue(SettingsID::GUI_OpenGLES))
{
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
format.setSwapInterval(0);
format.setMajorVersion(2);
format.setMinorVersion(0);
format.setRenderableType(QSurfaceFormat::OpenGLES);
QSurfaceFormat::setDefaultFormat(format);
}
else
{
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
format.setSwapInterval(0);
format.setMajorVersion(3);
format.setMinorVersion(3);
format.setRenderableType(QSurfaceFormat::OpenGL);
QSurfaceFormat::setDefaultFormat(format);
}

if (renderMode == VidExtRenderMode::OpenGL)
{
this->ui_Widget_OpenGL = new Widget::OGLWidget(this);
Expand Down
7 changes: 6 additions & 1 deletion Source/RMG/VidExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,16 @@ static m64p_error VidExt_InitWithRenderMode(m64p_render_mode RenderMode)
l_SurfaceFormat.setOption(QSurfaceFormat::DeprecatedFunctions, 1);
l_SurfaceFormat.setDepthBufferSize(24);
l_SurfaceFormat.setProfile(QSurfaceFormat::CompatibilityProfile);
l_SurfaceFormat.setSwapInterval(0);
if (l_SurfaceFormat.renderableType() != QSurfaceFormat::OpenGLES)
{
l_SurfaceFormat.setMajorVersion(3);
l_SurfaceFormat.setMinorVersion(3);
l_SurfaceFormat.setSwapInterval(0);
}
else
{
l_SurfaceFormat.setMajorVersion(2);
l_SurfaceFormat.setMinorVersion(0);
}
}

Expand Down

0 comments on commit e17685f

Please sign in to comment.