Plugins target frame rate and period.

This commit is contained in:
Howard Stearns 2015-12-02 16:40:41 -08:00
parent 861393910a
commit 8ae05d8490
6 changed files with 25 additions and 1 deletions

View file

@ -139,7 +139,8 @@ void Basic2DWindowOpenGLDisplayPlugin::updateFramerate() {
} else if (FRAMERATE_30 == actionText) {
_framerateTarget = 30;
}
}
}
_inverseFrameRate = _framerateTarget ? 1.0f / (float) _framerateTarget : 1.0f / TARGET_FRAMERATE_Basic2DWindowOpenGL; // not truncated
int newInterval = getDesiredInterval();
qDebug() << newInterval;

View file

@ -9,6 +9,8 @@
#include "WindowOpenGLDisplayPlugin.h"
#define TARGET_FRAMERATE_Basic2DWindowOpenGL 60.0f
class QScreen;
class Basic2DWindowOpenGLDisplayPlugin : public WindowOpenGLDisplayPlugin {
Q_OBJECT
@ -16,6 +18,9 @@ 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 void activate() override;
virtual void deactivate() override;
@ -33,4 +38,5 @@ private:
QScreen* getFullscreenTarget();
uint32_t _framerateTarget{ 0 };
int _fullscreenTarget{ -1 };
float _inverseFrameRate{ 1.0f }; //seconds
};

View file

@ -14,12 +14,17 @@
#include "../WindowOpenGLDisplayPlugin.h"
#define TARGET_RATE_OpenVr 90.0f; // FIXME: get from sdk tracked device property? This number is vive-only.
class OpenVrDisplayPlugin : public WindowOpenGLDisplayPlugin {
public:
virtual bool isSupported() const override;
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 void activate() override;
virtual void deactivate() override;

View file

@ -57,6 +57,8 @@ public:
/// By default, all HMDs are stereo
virtual bool isStereo() const { return isHmd(); }
virtual bool isThrottled() const { return false; }
virtual float getTargetFrameRate() { return 0.0f; }
virtual float getTargetFramePeriod() { return 0.0f; }
// Rendering support

View file

@ -12,12 +12,17 @@
struct SwapFramebufferWrapper;
using SwapFboPtr = QSharedPointer<SwapFramebufferWrapper>;
#define TARGET_RATE_Oculus 75.0f;
class OculusDisplayPlugin : public OculusBaseDisplayPlugin {
public:
virtual void activate() override;
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; }
protected:
virtual void display(GLuint finalTexture, const glm::uvec2& sceneSize) override;
virtual void customizeContext() override;

View file

@ -13,6 +13,8 @@
#include <OVR_CAPI.h>
#define TARGET_RATE_OculusLegacy 75.0f;
class OculusLegacyDisplayPlugin : public WindowOpenGLDisplayPlugin {
public:
OculusLegacyDisplayPlugin();
@ -25,6 +27,9 @@ 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; }
// Stereo specific methods
virtual bool isHmd() const override { return true; }
virtual glm::mat4 getProjection(Eye eye, const glm::mat4& baseProjection) const override;