Reimplement other missing options from current OpenGL renderer
This commit is contained in:
@@ -774,6 +774,8 @@ OpenGLRendererPCem::OpenGLRendererPCem(QWidget *parent)
|
|||||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES)
|
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES)
|
||||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||||
|
|
||||||
|
format.setSwapInterval(video_vsync ? 1 : 0);
|
||||||
|
|
||||||
setFormat(format);
|
setFormat(format);
|
||||||
|
|
||||||
parentWidget = parent;
|
parentWidget = parent;
|
||||||
@@ -822,6 +824,9 @@ OpenGLRendererPCem::initialize()
|
|||||||
glw.glEnable(GL_TEXTURE_2D);
|
glw.glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
//renderTimer->start(75);
|
//renderTimer->start(75);
|
||||||
|
if (video_framerate != -1) {
|
||||||
|
renderTimer->start(ceilf(1000.f / (float)video_framerate));
|
||||||
|
}
|
||||||
|
|
||||||
scene_texture.data = NULL;
|
scene_texture.data = NULL;
|
||||||
scene_texture.width = 2048;
|
scene_texture.width = 2048;
|
||||||
@@ -1102,6 +1107,7 @@ OpenGLRendererPCem::onBlit(int buf_idx, int x, int y, int w, int h)
|
|||||||
source.setRect(x, y, w, h);
|
source.setRect(x, y, w, h);
|
||||||
onResize(this->width(), this->height());
|
onResize(this->width(), this->height());
|
||||||
|
|
||||||
|
if (video_framerate == -1)
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1314,6 +1320,9 @@ OpenGLRendererPCem::render()
|
|||||||
if (!context)
|
if (!context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (notReady())
|
||||||
|
return;
|
||||||
|
|
||||||
int s, i, j;
|
int s, i, j;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#include "qt_openglshadermanagerdialog.hpp"
|
#include "qt_openglshadermanagerdialog.hpp"
|
||||||
#include "ui_qt_openglshadermanagerdialog.h"
|
#include "ui_qt_openglshadermanagerdialog.h"
|
||||||
|
|
||||||
|
#include "qt_mainwindow.hpp"
|
||||||
|
extern MainWindow* main_window;
|
||||||
|
|
||||||
#include "qt_openglshaderconfig.hpp"
|
#include "qt_openglshaderconfig.hpp"
|
||||||
|
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
@@ -25,6 +28,15 @@ OpenGLShaderManagerDialog::OpenGLShaderManagerDialog(QWidget *parent)
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
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++) {
|
for (int i = 0; i < MAX_USER_SHADERS; i++) {
|
||||||
if (gl3_shader_file[i][0] != 0) {
|
if (gl3_shader_file[i][0] != 0) {
|
||||||
char* filename = path_get_filename(gl3_shader_file[i]);
|
char* filename = path_get_filename(gl3_shader_file[i]);
|
||||||
@@ -75,6 +87,9 @@ void OpenGLShaderManagerDialog::on_buttonBox_clicked(QAbstractButton *button)
|
|||||||
accept();
|
accept();
|
||||||
} else if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::RejectRole) {
|
} else if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::RejectRole) {
|
||||||
reject();
|
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);
|
strncpy(gl3_shader_file[i], ui->shaderListWidget->item(i)->data(Qt::UserRole + 1).toString().toUtf8(), 512);
|
||||||
}
|
}
|
||||||
startblit();
|
startblit();
|
||||||
|
video_vsync = ui->checkBoxVSync->isChecked();
|
||||||
|
if (ui->radioButtonTargetFramerate->isChecked()) {
|
||||||
|
video_framerate = ui->horizontalSliderFramerate->value();
|
||||||
|
} else {
|
||||||
|
video_framerate = -1;
|
||||||
|
}
|
||||||
config_save();
|
config_save();
|
||||||
endblit();
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ private slots:
|
|||||||
|
|
||||||
void on_buttonConfigure_clicked();
|
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:
|
private:
|
||||||
Ui::OpenGLShaderManagerDialog *ui;
|
Ui::OpenGLShaderManagerDialog *ui;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,6 +13,15 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Shader Manager</string>
|
<string>Shader Manager</string>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SizeConstraint::SetFixedSize</enum>
|
||||||
|
</property>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBoxShaders">
|
||||||
|
<property name="title">
|
||||||
|
<string>Shaders</string>
|
||||||
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SizeConstraint::SetFixedSize</enum>
|
<enum>QLayout::SizeConstraint::SetFixedSize</enum>
|
||||||
@@ -29,6 +38,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SizeConstraint::SetFixedSize</enum>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="buttonAdd">
|
<widget class="QPushButton" name="buttonAdd">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -99,7 +111,7 @@
|
|||||||
<enum>Qt::Orientation::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
<set>QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="centerButtons">
|
<property name="centerButtons">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@@ -110,39 +122,83 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Render behavior</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
||||||
|
</property>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QRadioButton" name="radioButtonTargetFramerate">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use target framerate:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QSlider" name="horizontalSliderFramerate">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>15</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>240</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>60</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="invertedAppearance">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="invertedControls">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QRadioButton" name="radioButtonVideoSync">
|
||||||
|
<property name="text">
|
||||||
|
<string>Synchronize with video</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="checkBoxVSync">
|
||||||
|
<property name="text">
|
||||||
|
<string>VSync</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="targetFrameRate">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> fps</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>15</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>240</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>60</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>OpenGLShaderManagerDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>OpenGLShaderManagerDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user