isVSynchronized, and proper override declarations.

This commit is contained in:
Howard Stearns 2015-12-03 11:28:26 -08:00
parent ed86a88083
commit a989b926b0
6 changed files with 15 additions and 12 deletions

View file

@ -113,6 +113,9 @@ bool Basic2DWindowOpenGLDisplayPlugin::isThrottled() const {
return shouldThrottle;
}
bool Basic2DWindowOpenGLDisplayPlugin::isVSynchronized() const {
return (_framerateTarget == 0) && (!_vsyncAction || _vsyncAction->isChecked());
}
void Basic2DWindowOpenGLDisplayPlugin::updateFramerate() {
QAction* checkedFramerate{ nullptr };
@ -141,10 +144,8 @@ void Basic2DWindowOpenGLDisplayPlugin::updateFramerate() {
_inverseFrameRate = _framerateTarget ? 1.0f / (float) _framerateTarget : 1.0f / TARGET_FRAMERATE_Basic2DWindowOpenGL; // not truncated
int newInterval = getDesiredInterval();
if (_framerateTarget) { // For any target other than vsync, we have little hope of achieving it with timer alone:
const int ALLOWANCE_FOR_DISPLAY_FINISHFRAME_AND_TIMER = 3; // ideally a windowed average of qApp->getLastPaintWait and then some, but not worth the complexity
newInterval -= ALLOWANCE_FOR_DISPLAY_FINISHFRAME_AND_TIMER; // Otherwise, any controller expecting us to hit "target" will always be disappointed.
}
// Note: when not isVSynchronized, we are often not likely to hit target with a newInterval timer.
// We could try subtracting an allowance for qApp->getLastPaintWait() and qt timer machinery, but that starts getting complicated.
qDebug() << newInterval;
_timer.start(newInterval);
}

View file

@ -18,8 +18,8 @@ class Basic2DWindowOpenGLDisplayPlugin : public WindowOpenGLDisplayPlugin {
public:
virtual const QString & getName() const override;
virtual float getTargetFrameRate() { return _framerateTarget ? (float) _framerateTarget : TARGET_FRAMERATE_Basic2DWindowOpenGL; }
virtual float getTargetFramePeriod() { return _inverseFrameRate; }
virtual float getTargetFrameRate() override { return _framerateTarget ? (float) _framerateTarget : TARGET_FRAMERATE_Basic2DWindowOpenGL; }
virtual float getTargetFramePeriod() override { return _inverseFrameRate; }
virtual void activate() override;
virtual void deactivate() override;
@ -27,6 +27,7 @@ public:
virtual void display(GLuint sceneTexture, const glm::uvec2& sceneSize) override;
virtual bool isThrottled() const override;
virtual bool isVSynchronized() const override;
protected:
int getDesiredInterval() const;

View file

@ -22,8 +22,8 @@ public:
virtual const QString & getName() const override;
virtual bool isHmd() const override { return true; }
virtual float getTargetFrameRate() { return TARGET_RATE_OpenVr; }
virtual float getTargetFramePeriod() { return 1.0f / TARGET_RATE_OpenVr; }
virtual float getTargetFrameRate() override { return TARGET_RATE_OpenVr; }
virtual float getTargetFramePeriod() override { return 1.0f / TARGET_RATE_OpenVr; }
virtual void activate() override;
virtual void deactivate() override;

View file

@ -57,6 +57,7 @@ public:
/// By default, all HMDs are stereo
virtual bool isStereo() const { return isHmd(); }
virtual bool isThrottled() const { return false; }
virtual bool isVSynchronized() const { return true; } // false when throttled or run by non vsync timer
virtual float getTargetFrameRate() { return 0.0f; }
virtual float getTargetFramePeriod() { return 0.0f; }

View file

@ -20,8 +20,8 @@ public:
virtual void deactivate() override;
virtual const QString & getName() const override;
virtual float getTargetFrameRate() { return TARGET_RATE_Oculus; }
virtual float getTargetFramePeriod() { return 1.0f / TARGET_RATE_Oculus; }
virtual float getTargetFrameRate() override { return TARGET_RATE_Oculus; }
virtual float getTargetFramePeriod() override { return 1.0f / TARGET_RATE_Oculus; }
protected:
virtual void display(GLuint finalTexture, const glm::uvec2& sceneSize) override;

View file

@ -27,8 +27,8 @@ public:
virtual bool eventFilter(QObject* receiver, QEvent* event) override;
virtual int getHmdScreen() const override;
virtual float getTargetFrameRate() { return TARGET_RATE_OculusLegacy; }
virtual float getTargetFramePeriod() { return 1.0f / TARGET_RATE_OculusLegacy; }
virtual float getTargetFrameRate() override { return TARGET_RATE_OculusLegacy; }
virtual float getTargetFramePeriod() override { return 1.0f / TARGET_RATE_OculusLegacy; }
// Stereo specific methods
virtual bool isHmd() const override { return true; }