Commit 5dc75fec authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - shader animation callback now uses boost::timer which works on VC too.

parent 470f5427
......@@ -22,25 +22,13 @@
//
//---------------------------------------------------------------------------
#include <ctime>
#include <boost/date_time/local_time/local_time_types.hpp>
#include "WGEShaderAnimationCallback.h"
WGEShaderAnimationCallback::WGEShaderAnimationCallback( int ticksPerSecond ):
osg::Uniform::Callback(),
m_ticksPerSec( ticksPerSecond )
{
// TODO(ledig): gettimeofday should be available on windows too in sys/time.h
#ifndef _MSC_VER
timeval tv;
gettimeofday( &tv, 0L );
m_startUsec = tv.tv_sec * 1000000 + tv.tv_usec;
#else
m_timer.restart();
#endif
}
WGEShaderAnimationCallback::~WGEShaderAnimationCallback()
......@@ -50,16 +38,8 @@ WGEShaderAnimationCallback::~WGEShaderAnimationCallback()
void WGEShaderAnimationCallback::operator() ( osg::Uniform* uniform, osg::NodeVisitor* /*nv*/ )
{
#ifndef _MSC_VER
timeval tv;
gettimeofday( &tv, 0L );
int64_t currentUSecs = tv.tv_sec * 1000000 + tv.tv_usec;
int milli = static_cast< int >( ( currentUSecs - m_startUsec ) / ( 1000000 / m_ticksPerSec ) );
#else
// boost::timer measures seconds ... :-(
int milli = static_cast< int >( m_timer.elapsed() * 1000 );
#endif
uniform->set( milli );
// boost::timer measures seconds ...
int ticks = static_cast< int >( m_timer.elapsed() * m_ticksPerSec );
uniform->set( ticks );
}
......@@ -27,10 +27,7 @@
#include "stdint.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#ifdef _MSC_VER
#include <boost/timer.hpp>
#endif
#include <osg/Uniform>
#include "WExportWGE.h"
......@@ -64,17 +61,11 @@ public:
protected:
/**
* The microseconds where the callback has been created ( in unix time )
*/
int64_t m_startUsec;
/**
* Timer that stops the time hopefully OS independent
*/
#ifdef _MSC_VER
boost::timer m_timer;
#endif
/**
* Number of ticks to count per second.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment