mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 20:06:02 +02:00
remove vsync and framerate menus from 2d display plugin
This commit is contained in:
parent
e70be2d8fe
commit
86691d5d0e
1 changed files with 2 additions and 61 deletions
|
@ -18,13 +18,6 @@
|
||||||
const QString Basic2DWindowOpenGLDisplayPlugin::NAME("2D Display");
|
const QString Basic2DWindowOpenGLDisplayPlugin::NAME("2D Display");
|
||||||
|
|
||||||
static const QString FULLSCREEN = "Fullscreen";
|
static const QString FULLSCREEN = "Fullscreen";
|
||||||
static const QString FRAMERATE = DisplayPlugin::MENU_PATH() + ">Framerate";
|
|
||||||
static const QString FRAMERATE_UNLIMITED = "Unlimited";
|
|
||||||
static const QString FRAMERATE_60 = "60";
|
|
||||||
static const QString FRAMERATE_50 = "50";
|
|
||||||
static const QString FRAMERATE_40 = "40";
|
|
||||||
static const QString FRAMERATE_30 = "30";
|
|
||||||
static const QString VSYNC_ON = "V-Sync On";
|
|
||||||
|
|
||||||
const QString& Basic2DWindowOpenGLDisplayPlugin::getName() const {
|
const QString& Basic2DWindowOpenGLDisplayPlugin::getName() const {
|
||||||
return NAME;
|
return NAME;
|
||||||
|
@ -42,38 +35,12 @@ void Basic2DWindowOpenGLDisplayPlugin::activate() {
|
||||||
_container->unsetFullscreen();
|
_container->unsetFullscreen();
|
||||||
}
|
}
|
||||||
}, true, false);
|
}, true, false);
|
||||||
_container->addMenu(FRAMERATE);
|
|
||||||
_framerateActions.push_back(
|
|
||||||
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, FRAMERATE, FRAMERATE_UNLIMITED,
|
|
||||||
[this](bool) { updateFramerate(); }, true, true, FRAMERATE));
|
|
||||||
_framerateActions.push_back(
|
|
||||||
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, FRAMERATE, FRAMERATE_60,
|
|
||||||
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
|
||||||
_framerateActions.push_back(
|
|
||||||
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, FRAMERATE, FRAMERATE_50,
|
|
||||||
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
|
||||||
_framerateActions.push_back(
|
|
||||||
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, FRAMERATE, FRAMERATE_40,
|
|
||||||
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
|
||||||
_framerateActions.push_back(
|
|
||||||
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, FRAMERATE, FRAMERATE_30,
|
|
||||||
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
|
||||||
|
|
||||||
// Vsync detection happens in the parent class activate, so we need to check after that
|
|
||||||
if (_vsyncSupported) {
|
|
||||||
_vsyncAction = _container->addMenuItem(PluginType::DISPLAY_PLUGIN, MENU_PATH(), VSYNC_ON, [this](bool) {}, true, true);
|
|
||||||
} else {
|
|
||||||
_vsyncAction = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateFramerate();
|
updateFramerate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Basic2DWindowOpenGLDisplayPlugin::submitSceneTexture(uint32_t frameIndex, uint32_t sceneTexture, const glm::uvec2& sceneSize) {
|
void Basic2DWindowOpenGLDisplayPlugin::submitSceneTexture(uint32_t frameIndex, uint32_t sceneTexture, const glm::uvec2& sceneSize) {
|
||||||
if (_vsyncAction) {
|
_wantVsync = true; // always
|
||||||
_wantVsync = _vsyncAction->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowOpenGLDisplayPlugin::submitSceneTexture(frameIndex, sceneTexture, sceneSize);
|
WindowOpenGLDisplayPlugin::submitSceneTexture(frameIndex, sceneTexture, sceneSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,9 +54,7 @@ const uint32_t THROTTLED_FRAMERATE = 15;
|
||||||
int Basic2DWindowOpenGLDisplayPlugin::getDesiredInterval() const {
|
int Basic2DWindowOpenGLDisplayPlugin::getDesiredInterval() const {
|
||||||
static const int ULIMIITED_PAINT_TIMER_DELAY_MS = 1;
|
static const int ULIMIITED_PAINT_TIMER_DELAY_MS = 1;
|
||||||
int result = ULIMIITED_PAINT_TIMER_DELAY_MS;
|
int result = ULIMIITED_PAINT_TIMER_DELAY_MS;
|
||||||
if (0 != _framerateTarget) {
|
if (_isThrottled) {
|
||||||
result = MSECS_PER_SECOND / _framerateTarget;
|
|
||||||
} else if (_isThrottled) {
|
|
||||||
// This test wouldn't be necessary if we could depend on updateFramerate setting _framerateTarget.
|
// This test wouldn't be necessary if we could depend on updateFramerate setting _framerateTarget.
|
||||||
// Alas, that gets complicated: isThrottled() is const and other stuff depends on it.
|
// Alas, that gets complicated: isThrottled() is const and other stuff depends on it.
|
||||||
result = MSECS_PER_SECOND / THROTTLED_FRAMERATE;
|
result = MSECS_PER_SECOND / THROTTLED_FRAMERATE;
|
||||||
|
@ -112,30 +77,6 @@ bool Basic2DWindowOpenGLDisplayPlugin::isThrottled() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Basic2DWindowOpenGLDisplayPlugin::updateFramerate() {
|
void Basic2DWindowOpenGLDisplayPlugin::updateFramerate() {
|
||||||
QAction* checkedFramerate{ nullptr };
|
|
||||||
foreach(auto action, _framerateActions) {
|
|
||||||
if (action->isChecked()) {
|
|
||||||
checkedFramerate = action;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_framerateTarget = 0;
|
|
||||||
if (checkedFramerate) {
|
|
||||||
QString actionText = checkedFramerate->text();
|
|
||||||
if (FRAMERATE_60 == actionText) {
|
|
||||||
_framerateTarget = 60;
|
|
||||||
} else if (FRAMERATE_50 == actionText) {
|
|
||||||
_framerateTarget = 50;
|
|
||||||
} else if (FRAMERATE_40 == actionText) {
|
|
||||||
_framerateTarget = 40;
|
|
||||||
} else if (FRAMERATE_30 == actionText) {
|
|
||||||
_framerateTarget = 30;
|
|
||||||
}
|
|
||||||
} else if (_isThrottled) {
|
|
||||||
_framerateTarget = THROTTLED_FRAMERATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int newInterval = getDesiredInterval();
|
int newInterval = getDesiredInterval();
|
||||||
_timer.start(newInterval);
|
_timer.start(newInterval);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue