From Cory Slep and Robert Osfield, "When using Open Scene Graph and Qt on Android, the resulting thread that an application developer’s Q*Application is run on is different than what Qt considers the “main” thread, which can cause subtle problems. This is because Qt loads native libraries in one thread, and later runs the application in a different thread. They delay running in the second thread as long as possible as they have a nontrivial bootstrapping process. The motivation for Qt having this second thread is to allow them to remain responsive to both Java and native events, and capture events that would otherwise be “missed”
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.4@14964 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
parent
49c802153d
commit
f48a4baa4e
@ -15,6 +15,7 @@
|
||||
#include <osgQt/GraphicsWindowQt>
|
||||
#include <osgViewer/ViewerBase>
|
||||
#include <QInputEvent>
|
||||
#include <QPointer>
|
||||
|
||||
#if (QT_VERSION>=QT_VERSION_CHECK(4, 6, 0))
|
||||
# define USE_GESTURES
|
||||
@ -119,18 +120,24 @@ static QtKeyboardMap s_QtKeyboardMap;
|
||||
/// The object responsible for the scene re-rendering.
|
||||
class HeartBeat : public QObject {
|
||||
public:
|
||||
int _timerId;
|
||||
osg::Timer _lastFrameStartTime;
|
||||
osg::observer_ptr< osgViewer::ViewerBase > _viewer;
|
||||
int _timerId;
|
||||
osg::Timer _lastFrameStartTime;
|
||||
osg::observer_ptr< osgViewer::ViewerBase > _viewer;
|
||||
|
||||
HeartBeat();
|
||||
virtual ~HeartBeat();
|
||||
void init( osgViewer::ViewerBase *viewer );
|
||||
void stopTimer();
|
||||
void timerEvent( QTimerEvent *event );
|
||||
virtual ~HeartBeat();
|
||||
|
||||
void init( osgViewer::ViewerBase *viewer );
|
||||
void stopTimer();
|
||||
void timerEvent( QTimerEvent *event );
|
||||
|
||||
static HeartBeat* instance();
|
||||
private:
|
||||
HeartBeat();
|
||||
|
||||
static QPointer<HeartBeat> heartBeat;
|
||||
};
|
||||
|
||||
static HeartBeat heartBeat;
|
||||
QPointer<HeartBeat> HeartBeat::heartBeat;
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 2, 0))
|
||||
#define GETDEVICEPIXELRATIO() 1.0
|
||||
@ -955,7 +962,7 @@ void osgQt::initQtWindowingSystem()
|
||||
|
||||
void osgQt::setViewer( osgViewer::ViewerBase *viewer )
|
||||
{
|
||||
heartBeat.init( viewer );
|
||||
HeartBeat::instance()->init( viewer );
|
||||
}
|
||||
|
||||
|
||||
@ -971,6 +978,14 @@ HeartBeat::~HeartBeat()
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
HeartBeat* HeartBeat::instance()
|
||||
{
|
||||
if (!heartBeat)
|
||||
{
|
||||
heartBeat = new HeartBeat();
|
||||
}
|
||||
return heartBeat;
|
||||
}
|
||||
|
||||
void HeartBeat::stopTimer()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user