diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2011-04-20 13:01:18 +0200 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@nokia.com> | 2011-04-20 13:01:18 +0200 |
commit | 2f10198939ffcb51ab473d23abec5f77093ad5f3 (patch) | |
tree | bfef813337933ab601a0bda6fb5b9e5a6b292e30 | |
parent | 45e88bbb6940e07d7cfb6658db0429dd3732185f (diff) |
Force continuous updates.
-rw-r--r-- | ogreitem.cpp | 31 | ||||
-rw-r--r-- | ogreitem.h | 13 |
2 files changed, 11 insertions, 33 deletions
diff --git a/ogreitem.cpp b/ogreitem.cpp index 30f47d4..f4f6815 100644 --- a/ogreitem.cpp +++ b/ogreitem.cpp @@ -2,34 +2,21 @@ #include "ogrenode.h" #include "cameranodeobject.h" +#include <QtCore/QPropertyAnimation> + OgreItem::OgreItem(QSGItem *parent) : QSGItem(parent) , m_timerID(0) + , m_fakeAnim(this, "") { setFlag(ItemHasContents); - setTargetFPS(60); -} - -void OgreItem::setTargetFPS(int fps) -{ - if (fps == m_targetFPS) - return; - - m_targetFPS = fps; - - if (m_timerID) - killTimer(m_timerID); - //m_timerID = startTimer(1000 / m_targetFPS); - - emit targetFPSChanged(); -} - -void OgreItem::timerEvent(QTimerEvent *e) -{ - if (e->timerId() != m_timerID) - return; - update(); + // Hack to get continuous updates + m_fakeAnim.setDuration(10000); + m_fakeAnim.setStartValue(0); + m_fakeAnim.setEndValue(1); + m_fakeAnim.setLoopCount(-1); + m_fakeAnim.start(); } QSGNode *OgreItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) @@ -2,6 +2,7 @@ #define OGREITEM_H #include <QSGItem> +#include <QtCore/QPropertyAnimation> class CameraNodeObject; @@ -9,29 +10,19 @@ class OgreItem : public QSGItem { Q_OBJECT - Q_PROPERTY(int targetFPS READ targetFPS WRITE setTargetFPS NOTIFY targetFPSChanged) Q_PROPERTY(QObject *camera READ camera) public: OgreItem(QSGItem *parent = 0); - void setTargetFPS(int fps); - int targetFPS() const { return m_targetFPS; } - QObject *camera() const { return m_camera; } -Q_SIGNALS: - void targetFPSChanged(); - protected: virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); - void timerEvent(QTimerEvent *); - private: - int m_targetFPS; - int m_timerID; + QPropertyAnimation m_fakeAnim; QObject *m_camera; }; |