mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-22 17:03:18 +02:00
start working on the target framerate control
This commit is contained in:
parent
d13283192f
commit
ac269e16c0
5 changed files with 46 additions and 3 deletions
|
@ -94,6 +94,10 @@
|
||||||
|
|
||||||
#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
|
||||||
|
@ -177,8 +181,17 @@ 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),
|
||||||
_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);
|
||||||
|
|
||||||
|
@ -518,9 +531,16 @@ void Application::initializeGL() {
|
||||||
qDebug("Error: %s\n", glewGetErrorString(err));
|
qDebug("Error: %s\n", glewGetErrorString(err));
|
||||||
}
|
}
|
||||||
qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
||||||
|
|
||||||
|
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||||
|
wglSwapIntervalEXT(0);
|
||||||
|
int swapInterval = wglGetSwapIntervalEXT();
|
||||||
|
swapInterval++;
|
||||||
|
}
|
||||||
#endif
|
#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.
|
||||||
//viewFrustumOffsetCamera.setFieldOfView(90.0);
|
//viewFrustumOffsetCamera.setFieldOfView(90.0);
|
||||||
|
@ -1391,9 +1411,14 @@ void Application::idle() {
|
||||||
PerformanceWarning warn(showWarnings, "idle()");
|
PerformanceWarning warn(showWarnings, "idle()");
|
||||||
|
|
||||||
// Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran
|
// Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran
|
||||||
|
double targetFramePeriod = 0.0;
|
||||||
|
if (_renderTargetFramerate > 0) {
|
||||||
|
targetFramePeriod = 1000.0 / _renderTargetFramerate;
|
||||||
|
} else if (_renderTargetFramerate < 0) {
|
||||||
|
targetFramePeriod = IDLE_SIMULATE_MSECS;
|
||||||
|
}
|
||||||
double timeSinceLastUpdate = (double)_lastTimeUpdated.nsecsElapsed() / 1000000.0;
|
double timeSinceLastUpdate = (double)_lastTimeUpdated.nsecsElapsed() / 1000000.0;
|
||||||
if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
|
if (timeSinceLastUpdate > targetFramePeriod) {
|
||||||
_lastTimeUpdated.start();
|
_lastTimeUpdated.start();
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("update");
|
PerformanceTimer perfTimer("update");
|
||||||
|
@ -4138,6 +4163,10 @@ void Application::takeSnapshot() {
|
||||||
_snapshotShareDialog->show();
|
_snapshotShareDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::setRenderTargetFramerate(int framerate) {
|
||||||
|
_renderTargetFramerate = framerate;
|
||||||
|
}
|
||||||
|
|
||||||
void Application::setRenderResolutionScale(float scale) {
|
void Application::setRenderResolutionScale(float scale) {
|
||||||
_renderResolutionScale = scale;
|
_renderResolutionScale = scale;
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,6 +358,7 @@ public slots:
|
||||||
|
|
||||||
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
|
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
|
||||||
|
|
||||||
|
void setRenderTargetFramerate(int framerate);
|
||||||
void setRenderResolutionScale(float scale);
|
void setRenderResolutionScale(float scale);
|
||||||
|
|
||||||
void resetSensors();
|
void resetSensors();
|
||||||
|
@ -609,6 +610,7 @@ private:
|
||||||
quint64 _lastNackTime;
|
quint64 _lastNackTime;
|
||||||
quint64 _lastSendDownstreamAudioStats;
|
quint64 _lastSendDownstreamAudioStats;
|
||||||
|
|
||||||
|
int _renderTargetFramerate;
|
||||||
float _renderResolutionScale;
|
float _renderResolutionScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
const int MSECS_PER_FRAME_WHEN_THROTTLED = 66;
|
const int MSECS_PER_FRAME_WHEN_THROTTLED = 66;
|
||||||
|
|
||||||
GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer)),
|
GLCanvas::GLCanvas() : QGLWidget(QGL::NoDepthBuffer | QGL::NoStencilBuffer),
|
||||||
_throttleRendering(false),
|
_throttleRendering(false),
|
||||||
_idleRenderInterval(MSECS_PER_FRAME_WHEN_THROTTLED)
|
_idleRenderInterval(MSECS_PER_FRAME_WHEN_THROTTLED)
|
||||||
{
|
{
|
||||||
|
|
|
@ -372,6 +372,8 @@ 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* resolutionMenu = renderOptionsMenu->addMenu(MenuOption::RenderResolution);
|
QMenu* resolutionMenu = renderOptionsMenu->addMenu(MenuOption::RenderResolution);
|
||||||
QActionGroup* resolutionGroup = new QActionGroup(resolutionMenu);
|
QActionGroup* resolutionGroup = new QActionGroup(resolutionMenu);
|
||||||
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionOne, 0, false));
|
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionOne, 0, false));
|
||||||
|
@ -1230,6 +1232,14 @@ void Menu::muteEnvironment() {
|
||||||
free(packet);
|
free(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Menu::toggleUnleashFramerate() {
|
||||||
|
if (isOptionChecked(MenuOption::RenderUnleashFramerate)) {
|
||||||
|
Application::getInstance()->setRenderTargetFramerate(0);
|
||||||
|
} else {
|
||||||
|
Application::getInstance()->setRenderTargetFramerate(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Menu::changeRenderResolution(QAction* action) {
|
void Menu::changeRenderResolution(QAction* action) {
|
||||||
QString text = action->text();
|
QString text = action->text();
|
||||||
if (text == MenuOption::RenderResolutionOne) {
|
if (text == MenuOption::RenderResolutionOne) {
|
||||||
|
|
|
@ -227,6 +227,7 @@ private slots:
|
||||||
void displayAddressOfflineMessage();
|
void displayAddressOfflineMessage();
|
||||||
void displayAddressNotFoundMessage();
|
void displayAddressNotFoundMessage();
|
||||||
void muteEnvironment();
|
void muteEnvironment();
|
||||||
|
void toggleUnleashFramerate();
|
||||||
void changeRenderResolution(QAction* action);
|
void changeRenderResolution(QAction* action);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -446,6 +447,7 @@ namespace MenuOption {
|
||||||
const QString RenderHeadCollisionShapes = "Show Head Collision Shapes";
|
const QString RenderHeadCollisionShapes = "Show Head Collision Shapes";
|
||||||
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 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";
|
||||||
|
|
Loading…
Reference in a new issue