mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
framerate is as fast as the display can go
This commit is contained in:
parent
5b0fd99115
commit
80a87b3b44
6 changed files with 114 additions and 27 deletions
|
@ -33,7 +33,7 @@ elseif (WIN32)
|
||||||
add_definitions(-D_USE_MATH_DEFINES) # apparently needed to get M_PI and other defines from cmath/math.h
|
add_definitions(-D_USE_MATH_DEFINES) # apparently needed to get M_PI and other defines from cmath/math.h
|
||||||
add_definitions(-DWINDOWS_LEAN_AND_MEAN) # needed to make sure windows doesn't go to crazy with its defines
|
add_definitions(-DWINDOWS_LEAN_AND_MEAN) # needed to make sure windows doesn't go to crazy with its defines
|
||||||
|
|
||||||
set(GL_HEADERS "#include <windowshacks.h>\n#include <GL/glew.h>\n#include <GL/glut.h>")
|
set(GL_HEADERS "#include <windowshacks.h>\n#include <GL/glew.h>\n#include <GL/glut.h>\n#include <GL/wglew.h>")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# set up the external glm library
|
# set up the external glm library
|
||||||
|
|
|
@ -94,10 +94,6 @@
|
||||||
|
|
||||||
#include "devices/Leapmotion.h"
|
#include "devices/Leapmotion.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <gl/wglew.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// Starfield information
|
// Starfield information
|
||||||
|
@ -183,17 +179,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_trayIcon(new QSystemTrayIcon(_window)),
|
_trayIcon(new QSystemTrayIcon(_window)),
|
||||||
_lastNackTime(usecTimestampNow()),
|
_lastNackTime(usecTimestampNow()),
|
||||||
_lastSendDownstreamAudioStats(usecTimestampNow()),
|
_lastSendDownstreamAudioStats(usecTimestampNow()),
|
||||||
_renderTargetFramerate(60),
|
_renderTargetFramerate(0),
|
||||||
|
_isVSyncOn(true),
|
||||||
_renderResolutionScale(1.0f)
|
_renderResolutionScale(1.0f)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/* QGLFormat trueFormat = _glWidget->format();
|
|
||||||
trueFormat.setSwapInterval(0);
|
|
||||||
_glWidget->setFormat(trueFormat);*/
|
|
||||||
int swapInterval = _glWidget->format().swapInterval();
|
|
||||||
swapInterval++;
|
|
||||||
|
|
||||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||||
QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||||
|
|
||||||
|
@ -535,13 +525,18 @@ void Application::initializeGL() {
|
||||||
qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
||||||
|
|
||||||
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||||
wglSwapIntervalEXT(0);
|
|
||||||
int swapInterval = wglGetSwapIntervalEXT();
|
int swapInterval = wglGetSwapIntervalEXT();
|
||||||
swapInterval++;
|
qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Q_OS_LINUX)
|
||||||
|
// TODO: Write the correct code for Linux...
|
||||||
|
/* if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||||
|
int swapInterval = wglGetSwapIntervalEXT();
|
||||||
|
qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
||||||
|
}*/
|
||||||
|
#endif
|
||||||
|
|
||||||
// Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large
|
// Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large
|
||||||
// field of view and near and far clip to make it interesting.
|
// field of view and near and far clip to make it interesting.
|
||||||
|
@ -4168,10 +4163,53 @@ void Application::takeSnapshot() {
|
||||||
_snapshotShareDialog->show();
|
_snapshotShareDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setRenderTargetFramerate(int framerate) {
|
void Application::setRenderTargetFramerate(unsigned int framerate, bool vsyncOn) {
|
||||||
|
if (vsyncOn != _isVSyncOn) {
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||||
|
wglSwapIntervalEXT(vsyncOn);
|
||||||
|
int swapInterval = wglGetSwapIntervalEXT();
|
||||||
|
_isVSyncOn = swapInterval;
|
||||||
|
qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
||||||
|
} else {
|
||||||
|
qDebug("V-Sync is FORCED ON on this system\n");
|
||||||
|
}
|
||||||
|
#elif defined(Q_OS_LINUX)
|
||||||
|
// TODO: write the poper code for linux
|
||||||
|
/*
|
||||||
|
if (glQueryExtension.... ("GLX_EXT_swap_control")) {
|
||||||
|
glxSwapIntervalEXT(vsyncOn);
|
||||||
|
int swapInterval = xglGetSwapIntervalEXT();
|
||||||
|
_isVSyncOn = swapInterval;
|
||||||
|
qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
||||||
|
} else {
|
||||||
|
qDebug("V-Sync is FORCED ON on this system\n");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#else
|
||||||
|
qDebug("V-Sync is FORCED ON on this system\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
_renderTargetFramerate = framerate;
|
_renderTargetFramerate = framerate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::isVSyncEditable() {
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#elif defined(Q_OS_LINUX)
|
||||||
|
// TODO: write the poper code for linux
|
||||||
|
/*
|
||||||
|
if (glQueryExtension.... ("GLX_EXT_swap_control")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Application::setRenderResolutionScale(float scale) {
|
void Application::setRenderResolutionScale(float scale) {
|
||||||
_renderResolutionScale = scale;
|
_renderResolutionScale = scale;
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,7 +361,11 @@ public slots:
|
||||||
|
|
||||||
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
|
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
|
||||||
|
|
||||||
void setRenderTargetFramerate(int framerate);
|
void setRenderTargetFramerate(unsigned int framerate, bool vsyncOn = true);
|
||||||
|
bool isVSyncOn() { return _isVSyncOn; }
|
||||||
|
bool isVSyncEditable();
|
||||||
|
unsigned int getRenderTargetFramerate() const { return _renderTargetFramerate; }
|
||||||
|
|
||||||
void setRenderResolutionScale(float scale);
|
void setRenderResolutionScale(float scale);
|
||||||
|
|
||||||
void resetSensors();
|
void resetSensors();
|
||||||
|
@ -615,6 +619,7 @@ private:
|
||||||
quint64 _lastSendDownstreamAudioStats;
|
quint64 _lastSendDownstreamAudioStats;
|
||||||
|
|
||||||
int _renderTargetFramerate;
|
int _renderTargetFramerate;
|
||||||
|
bool _isVSyncOn;
|
||||||
float _renderResolutionScale;
|
float _renderResolutionScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -373,7 +373,23 @@ Menu::Menu() :
|
||||||
shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::SimpleShadows, 0, false));
|
shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::SimpleShadows, 0, false));
|
||||||
shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::CascadedShadows, 0, false));
|
shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::CascadedShadows, 0, false));
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderUnleashFramerate, 0, false, this, SLOT(toggleUnleashFramerate()));
|
{
|
||||||
|
QMenu* framerateMenu = renderOptionsMenu->addMenu(MenuOption::RenderTargetFramerate);
|
||||||
|
QActionGroup* framerateGroup = new QActionGroup(framerateMenu);
|
||||||
|
|
||||||
|
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerateUnlimited, 0, true));
|
||||||
|
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate60, 0, false));
|
||||||
|
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate50, 0, false));
|
||||||
|
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate40, 0, false));
|
||||||
|
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate30, 0, false));
|
||||||
|
connect(framerateMenu, SIGNAL(triggered(QAction*)), this, SLOT(changeRenderTargetFramerate(QAction*)));
|
||||||
|
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
#else
|
||||||
|
QAction* vsyncAction = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderTargetFramerateVSyncOn, 0, true, this, SLOT(changeVSync()));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QMenu* resolutionMenu = renderOptionsMenu->addMenu(MenuOption::RenderResolution);
|
QMenu* resolutionMenu = renderOptionsMenu->addMenu(MenuOption::RenderResolution);
|
||||||
QActionGroup* resolutionGroup = new QActionGroup(resolutionMenu);
|
QActionGroup* resolutionGroup = new QActionGroup(resolutionMenu);
|
||||||
|
@ -1237,11 +1253,30 @@ void Menu::muteEnvironment() {
|
||||||
free(packet);
|
free(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::toggleUnleashFramerate() {
|
void Menu::changeVSync() {
|
||||||
if (isOptionChecked(MenuOption::RenderUnleashFramerate)) {
|
Application::getInstance()->setRenderTargetFramerate(
|
||||||
Application::getInstance()->setRenderTargetFramerate(0);
|
Application::getInstance()->getRenderTargetFramerate(),
|
||||||
} else {
|
isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn));
|
||||||
Application::getInstance()->setRenderTargetFramerate(-1);
|
}
|
||||||
|
void Menu::changeRenderTargetFramerate(QAction* action) {
|
||||||
|
bool vsynOn = Application::getInstance()->isVSyncOn();
|
||||||
|
unsigned int framerate = Application::getInstance()->getRenderTargetFramerate();
|
||||||
|
|
||||||
|
QString text = action->text();
|
||||||
|
if (text == MenuOption::RenderTargetFramerateUnlimited) {
|
||||||
|
Application::getInstance()->setRenderTargetFramerate(0, vsynOn);
|
||||||
|
}
|
||||||
|
else if (text == MenuOption::RenderTargetFramerate60) {
|
||||||
|
Application::getInstance()->setRenderTargetFramerate(60, vsynOn);
|
||||||
|
}
|
||||||
|
else if (text == MenuOption::RenderTargetFramerate50) {
|
||||||
|
Application::getInstance()->setRenderTargetFramerate(50, vsynOn);
|
||||||
|
}
|
||||||
|
else if (text == MenuOption::RenderTargetFramerate40) {
|
||||||
|
Application::getInstance()->setRenderTargetFramerate(40, vsynOn);
|
||||||
|
}
|
||||||
|
else if (text == MenuOption::RenderTargetFramerate30) {
|
||||||
|
Application::getInstance()->setRenderTargetFramerate(30, vsynOn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,8 @@ private slots:
|
||||||
void displayAddressOfflineMessage();
|
void displayAddressOfflineMessage();
|
||||||
void displayAddressNotFoundMessage();
|
void displayAddressNotFoundMessage();
|
||||||
void muteEnvironment();
|
void muteEnvironment();
|
||||||
void toggleUnleashFramerate();
|
void changeRenderTargetFramerate(QAction* action);
|
||||||
|
void changeVSync();
|
||||||
void changeRenderResolution(QAction* action);
|
void changeRenderResolution(QAction* action);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -453,7 +454,14 @@ namespace MenuOption {
|
||||||
const QString RenderHeightfields = "Render Heightfields";
|
const QString RenderHeightfields = "Render Heightfields";
|
||||||
const QString RenderLookAtVectors = "Show Look-at Vectors";
|
const QString RenderLookAtVectors = "Show Look-at Vectors";
|
||||||
const QString RenderSkeletonCollisionShapes = "Show Skeleton Collision Shapes";
|
const QString RenderSkeletonCollisionShapes = "Show Skeleton Collision Shapes";
|
||||||
const QString RenderUnleashFramerate = "Unleash Framerate";
|
const QString RenderTargetFramerate = "Framerate";
|
||||||
|
const QString RenderTargetFramerateUnlimited = "Unlimited";
|
||||||
|
const QString RenderTargetFramerate60 = "60";
|
||||||
|
const QString RenderTargetFramerate50 = "50";
|
||||||
|
const QString RenderTargetFramerate40 = "40";
|
||||||
|
const QString RenderTargetFramerate30 = "30";
|
||||||
|
const QString RenderTargetFramerateVSyncOn = "V-Sync On";
|
||||||
|
|
||||||
const QString RenderResolution = "Scale Resolution";
|
const QString RenderResolution = "Scale Resolution";
|
||||||
const QString RenderResolutionOne = "1";
|
const QString RenderResolutionOne = "1";
|
||||||
const QString RenderResolutionTwoThird = "2/3";
|
const QString RenderResolutionTwoThird = "2/3";
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
//#define DO_IT_NOW(call, offset) runLastCommand();
|
//#define DO_IT_NOW(call, offset) runLastCommand();
|
||||||
#define DO_IT_NOW(call, offset)
|
#define DO_IT_NOW(call, offset)
|
||||||
|
|
||||||
#define CHECK_GL_ERROR() ::gpu::backend::checkGLError()
|
//#define CHECK_GL_ERROR() ::gpu::backend::checkGLError()
|
||||||
|
#define CHECK_GL_ERROR()
|
||||||
|
|
||||||
using namespace gpu;
|
using namespace gpu;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue