add back vsync

This commit is contained in:
RSDuck
2022-10-04 13:15:50 +02:00
parent 7e09c23f1d
commit 2f0c89cbe9
2 changed files with 20 additions and 15 deletions

View File

@ -28,6 +28,11 @@
#include "ui_VideoSettingsDialog.h"
inline bool UsesGL()
{
return (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0);
}
VideoSettingsDialog* VideoSettingsDialog::currentDlg = nullptr;
@ -88,14 +93,6 @@ VideoSettingsDialog::VideoSettingsDialog(QWidget* parent) : QDialog(parent), ui(
ui->cbxGLResolution->setEnabled(true);
ui->cbBetterPolygons->setEnabled(true);
}
// sorry
ui->cbVSync->hide();
ui->cbVSync->setEnabled(false);
ui->sbVSyncInterval->hide();
ui->sbVSyncInterval->setEnabled(false);
ui->label_2->hide();
ui->groupBox->layout()->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
VideoSettingsDialog::~VideoSettingsDialog()
@ -112,7 +109,7 @@ void VideoSettingsDialog::on_VideoSettingsDialog_accepted()
void VideoSettingsDialog::on_VideoSettingsDialog_rejected()
{
bool old_gl = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0);
bool old_gl = UsesGL();
Config::_3DRenderer = oldRenderer;
Config::ScreenUseGL = oldGLDisplay;
@ -122,8 +119,7 @@ void VideoSettingsDialog::on_VideoSettingsDialog_rejected()
Config::GL_ScaleFactor = oldGLScale;
Config::GL_BetterPolygons = oldGLBetterPolygons;
bool new_gl = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0);
emit updateVideoSettings(old_gl != new_gl);
emit updateVideoSettings(old_gl != UsesGL());
closeDlg();
}
@ -149,8 +145,7 @@ void VideoSettingsDialog::onChange3DRenderer(int renderer)
ui->cbBetterPolygons->setEnabled(true);
}
bool new_gl = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0);
emit updateVideoSettings(old_gl != new_gl);
emit updateVideoSettings(old_gl != UsesGL());
}
void VideoSettingsDialog::on_cbGLDisplay_stateChanged(int state)
@ -159,8 +154,7 @@ void VideoSettingsDialog::on_cbGLDisplay_stateChanged(int state)
Config::ScreenUseGL = (state != 0);
bool new_gl = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0);
emit updateVideoSettings(old_gl != new_gl);
emit updateVideoSettings(old_gl != UsesGL());
}
void VideoSettingsDialog::on_cbVSync_stateChanged(int state)
@ -168,11 +162,13 @@ void VideoSettingsDialog::on_cbVSync_stateChanged(int state)
bool vsync = (state != 0);
ui->sbVSyncInterval->setEnabled(vsync);
Config::ScreenVSync = vsync;
emit updateVideoSettings(false);
}
void VideoSettingsDialog::on_sbVSyncInterval_valueChanged(int val)
{
Config::ScreenVSyncInterval = val;
emit updateVideoSettings(false);
}
void VideoSettingsDialog::on_cbSoftwareThreaded_stateChanged(int state)

View File

@ -426,6 +426,8 @@ void EmuThread::initOpenGL()
static_cast<ScreenPanelGL*>(mainWindow->panel)->transferLayout(this);
OSD::Init(true);
oglContext->SetSwapInterval(Config::ScreenVSync ? Config::ScreenVSyncInterval : 0);
}
void EmuThread::deinitOpenGL()
@ -543,7 +545,9 @@ void EmuThread::run()
videoRenderer = 0;
}
else
{
videoRenderer = hasOGL ? Config::_3DRenderer : 0;
}
videoSettingsDirty = false;
@ -551,6 +555,11 @@ void EmuThread::run()
videoSettings.GL_ScaleFactor = Config::GL_ScaleFactor;
videoSettings.GL_BetterPolygons = Config::GL_BetterPolygons;
if (hasOGL)
{
oglContext->SetSwapInterval(Config::ScreenVSync ? Config::ScreenVSyncInterval : 0);
}
GPU::SetRenderSettings(videoRenderer, videoSettings);
}