forked from mirror/openmw-tes3mp
Clang warning fix
This commit is contained in:
parent
8c44334409
commit
0d439750a2
2 changed files with 0 additions and 133 deletions
10
extern/osgQt/GraphicsWindowQt
vendored
10
extern/osgQt/GraphicsWindowQt
vendored
|
@ -37,16 +37,6 @@ namespace osgQt
|
|||
// forward declarations
|
||||
class GraphicsWindowQt;
|
||||
|
||||
/** The function sets the viewer that will be used after entering
|
||||
* the Qt main loop (QCoreApplication::exec()).
|
||||
*
|
||||
* The function also initializes internal structures required for proper
|
||||
* scene rendering.
|
||||
*
|
||||
* The method must be called from main thread. */
|
||||
void setViewer( osgViewer::ViewerBase *viewer );
|
||||
|
||||
|
||||
class GLWidget : public QGLWidget
|
||||
{
|
||||
typedef QGLWidget inherited;
|
||||
|
|
123
extern/osgQt/GraphicsWindowQt.cpp
vendored
123
extern/osgQt/GraphicsWindowQt.cpp
vendored
|
@ -26,28 +26,6 @@
|
|||
|
||||
using namespace osgQt;
|
||||
|
||||
/// The object responsible for the scene re-rendering.
|
||||
class HeartBeat : public QObject {
|
||||
public:
|
||||
int _timerId;
|
||||
osg::Timer _lastFrameStartTime;
|
||||
osg::observer_ptr< osgViewer::ViewerBase > _viewer;
|
||||
|
||||
virtual ~HeartBeat();
|
||||
|
||||
void init( osgViewer::ViewerBase *viewer );
|
||||
void stopTimer();
|
||||
void timerEvent( QTimerEvent *event );
|
||||
|
||||
static HeartBeat* instance();
|
||||
private:
|
||||
HeartBeat();
|
||||
|
||||
static QPointer<HeartBeat> heartBeat;
|
||||
};
|
||||
|
||||
QPointer<HeartBeat> HeartBeat::heartBeat;
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 2, 0))
|
||||
#define GETDEVICEPIXELRATIO() 1.0
|
||||
#else
|
||||
|
@ -637,104 +615,3 @@ private:
|
|||
QtWindowingSystem& operator=( const QtWindowingSystem& );
|
||||
};
|
||||
|
||||
|
||||
void osgQt::setViewer( osgViewer::ViewerBase *viewer )
|
||||
{
|
||||
HeartBeat::instance()->init( viewer );
|
||||
}
|
||||
|
||||
|
||||
/// Constructor. Must be called from main thread.
|
||||
HeartBeat::HeartBeat() : _timerId( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// Destructor. Must be called from main thread.
|
||||
HeartBeat::~HeartBeat()
|
||||
{
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
HeartBeat* HeartBeat::instance()
|
||||
{
|
||||
if (!heartBeat)
|
||||
{
|
||||
heartBeat = new HeartBeat();
|
||||
}
|
||||
return heartBeat;
|
||||
}
|
||||
|
||||
void HeartBeat::stopTimer()
|
||||
{
|
||||
if ( _timerId != 0 )
|
||||
{
|
||||
killTimer( _timerId );
|
||||
_timerId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Initializes the loop for viewer. Must be called from main thread.
|
||||
void HeartBeat::init( osgViewer::ViewerBase *viewer )
|
||||
{
|
||||
if( _viewer == viewer )
|
||||
return;
|
||||
|
||||
stopTimer();
|
||||
|
||||
_viewer = viewer;
|
||||
|
||||
if( viewer )
|
||||
{
|
||||
_timerId = startTimer( 0 );
|
||||
_lastFrameStartTime.setStartTick( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HeartBeat::timerEvent( QTimerEvent * /*event*/ )
|
||||
{
|
||||
osg::ref_ptr< osgViewer::ViewerBase > viewer;
|
||||
if( !_viewer.lock( viewer ) )
|
||||
{
|
||||
// viewer has been deleted -> stop timer
|
||||
stopTimer();
|
||||
return;
|
||||
}
|
||||
|
||||
// limit the frame rate
|
||||
if( viewer->getRunMaxFrameRate() > 0.0)
|
||||
{
|
||||
double dt = _lastFrameStartTime.time_s();
|
||||
double minFrameTime = 1.0 / viewer->getRunMaxFrameRate();
|
||||
if (dt < minFrameTime)
|
||||
OpenThreads::Thread::microSleep(static_cast<unsigned int>(1000000.0*(minFrameTime-dt)));
|
||||
}
|
||||
else
|
||||
{
|
||||
// avoid excessive CPU loading when no frame is required in ON_DEMAND mode
|
||||
if( viewer->getRunFrameScheme() == osgViewer::ViewerBase::ON_DEMAND )
|
||||
{
|
||||
double dt = _lastFrameStartTime.time_s();
|
||||
if (dt < 0.01)
|
||||
OpenThreads::Thread::microSleep(static_cast<unsigned int>(1000000.0*(0.01-dt)));
|
||||
}
|
||||
|
||||
// record start frame time
|
||||
_lastFrameStartTime.setStartTick();
|
||||
|
||||
// make frame
|
||||
if( viewer->getRunFrameScheme() == osgViewer::ViewerBase::ON_DEMAND )
|
||||
{
|
||||
if( viewer->checkNeedToDoFrame() )
|
||||
{
|
||||
viewer->frame();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
viewer->frame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue