diff --git a/src/qt/qt_openglrenderer_pcem.cpp b/src/qt/qt_openglrenderer_pcem.cpp index 50583bf51..79960323f 100644 --- a/src/qt/qt_openglrenderer_pcem.cpp +++ b/src/qt/qt_openglrenderer_pcem.cpp @@ -774,6 +774,8 @@ OpenGLRendererPCem::OpenGLRendererPCem(QWidget *parent) if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) format.setRenderableType(QSurfaceFormat::OpenGLES); + format.setSwapInterval(video_vsync ? 1 : 0); + setFormat(format); parentWidget = parent; @@ -822,6 +824,9 @@ OpenGLRendererPCem::initialize() glw.glEnable(GL_TEXTURE_2D); //renderTimer->start(75); + if (video_framerate != -1) { + renderTimer->start(ceilf(1000.f / (float)video_framerate)); + } scene_texture.data = NULL; scene_texture.width = 2048; @@ -1102,7 +1107,8 @@ OpenGLRendererPCem::onBlit(int buf_idx, int x, int y, int w, int h) source.setRect(x, y, w, h); onResize(this->width(), this->height()); - render(); + if (video_framerate == -1) + render(); } std::vector> @@ -1314,6 +1320,9 @@ OpenGLRendererPCem::render() if (!context) return; + if (notReady()) + return; + int s, i, j; struct { diff --git a/src/qt/qt_openglshadermanagerdialog.cpp b/src/qt/qt_openglshadermanagerdialog.cpp index 08cf94fd7..0bf083252 100644 --- a/src/qt/qt_openglshadermanagerdialog.cpp +++ b/src/qt/qt_openglshadermanagerdialog.cpp @@ -1,6 +1,9 @@ #include "qt_openglshadermanagerdialog.hpp" #include "ui_qt_openglshadermanagerdialog.h" +#include "qt_mainwindow.hpp" +extern MainWindow* main_window; + #include "qt_openglshaderconfig.hpp" #include @@ -25,6 +28,15 @@ OpenGLShaderManagerDialog::OpenGLShaderManagerDialog(QWidget *parent) { ui->setupUi(this); + ui->checkBoxVSync->setChecked(!!video_vsync); + ui->radioButtonVideoSync->setChecked(video_framerate == -1); + ui->radioButtonTargetFramerate->setChecked(video_framerate != -1); + if (video_framerate != -1) { + ui->targetFrameRate->setValue(video_framerate); + } else { + ui->targetFrameRate->setDisabled(true); + } + for (int i = 0; i < MAX_USER_SHADERS; i++) { if (gl3_shader_file[i][0] != 0) { char* filename = path_get_filename(gl3_shader_file[i]); @@ -75,6 +87,9 @@ void OpenGLShaderManagerDialog::on_buttonBox_clicked(QAbstractButton *button) accept(); } else if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::RejectRole) { reject(); + } else if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) { + on_OpenGLShaderManagerDialog_accepted(); + main_window->reloadAllRenderers(); } } @@ -191,6 +206,12 @@ void OpenGLShaderManagerDialog::on_OpenGLShaderManagerDialog_accepted() strncpy(gl3_shader_file[i], ui->shaderListWidget->item(i)->data(Qt::UserRole + 1).toString().toUtf8(), 512); } startblit(); + video_vsync = ui->checkBoxVSync->isChecked(); + if (ui->radioButtonTargetFramerate->isChecked()) { + video_framerate = ui->horizontalSliderFramerate->value(); + } else { + video_framerate = -1; + } config_save(); endblit(); } @@ -207,3 +228,33 @@ void OpenGLShaderManagerDialog::on_buttonConfigure_clicked() } } + +void OpenGLShaderManagerDialog::on_radioButtonVideoSync_clicked() +{ + ui->targetFrameRate->setDisabled(true); +} + + +void OpenGLShaderManagerDialog::on_radioButtonTargetFramerate_clicked() +{ + ui->targetFrameRate->setDisabled(false); +} + + +void OpenGLShaderManagerDialog::on_horizontalSliderFramerate_sliderMoved(int position) +{ + (void)position; + + if (ui->horizontalSliderFramerate->value() != ui->targetFrameRate->value()) + ui->targetFrameRate->setValue(ui->horizontalSliderFramerate->value()); +} + + +void OpenGLShaderManagerDialog::on_targetFrameRate_valueChanged(int arg1) +{ + (void)arg1; + + if (ui->horizontalSliderFramerate->value() != ui->targetFrameRate->value()) + ui->horizontalSliderFramerate->setValue(ui->targetFrameRate->value()); +} + diff --git a/src/qt/qt_openglshadermanagerdialog.hpp b/src/qt/qt_openglshadermanagerdialog.hpp index b8885e3a3..a9f7ad3a9 100644 --- a/src/qt/qt_openglshadermanagerdialog.hpp +++ b/src/qt/qt_openglshadermanagerdialog.hpp @@ -35,6 +35,14 @@ private slots: void on_buttonConfigure_clicked(); + void on_radioButtonVideoSync_clicked(); + + void on_radioButtonTargetFramerate_clicked(); + + void on_horizontalSliderFramerate_sliderMoved(int position); + + void on_targetFrameRate_valueChanged(int arg1); + private: Ui::OpenGLShaderManagerDialog *ui; }; diff --git a/src/qt/qt_openglshadermanagerdialog.ui b/src/qt/qt_openglshadermanagerdialog.ui index f68827436..2a72c69ed 100644 --- a/src/qt/qt_openglshadermanagerdialog.ui +++ b/src/qt/qt_openglshadermanagerdialog.ui @@ -13,136 +13,192 @@ Shader Manager - + QLayout::SizeConstraint::SetFixedSize - - - - QAbstractItemView::DragDropMode::InternalMove - - - QAbstractItemView::SelectionBehavior::SelectItems + + + + Shaders + + + QLayout::SizeConstraint::SetFixedSize + + + + + QAbstractItemView::DragDropMode::InternalMove + + + QAbstractItemView::SelectionBehavior::SelectItems + + + + + + + QLayout::SizeConstraint::SetFixedSize + + + + + Add + + + + + + + Remove + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + true + + + Configure + + + + + + + Move up + + + + + + + Move down + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + Qt::Orientation::Vertical + + + QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok + + + false + + + + + + - - - - - - Add - - - - - - - Remove - - - - - - - Qt::Orientation::Vertical - - - - 20 - 40 - - - - - - - - true - - - Configure - - - - - - - Move up - - - - - - - Move down - - - - - - - Qt::Orientation::Vertical - - - - 20 - 40 - - - - - - - - Qt::Orientation::Vertical - - - QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok - - - false - - - - + + + + Render behavior + + + + QLayout::SizeConstraint::SetDefaultConstraint + + + + + Use target framerate: + + + + + + + 15 + + + 240 + + + 60 + + + Qt::Orientation::Horizontal + + + false + + + false + + + + + + + Synchronize with video + + + true + + + + + + + VSync + + + + + + + fps + + + 15 + + + 240 + + + 60 + + + + + - - - buttonBox - accepted() - OpenGLShaderManagerDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - OpenGLShaderManagerDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - +