Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
5dc75fec
Commit
5dc75fec
authored
Aug 10, 2010
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CHANGE] - shader animation callback now uses boost::timer which works on VC too.
parent
470f5427
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
33 deletions
+4
-33
src/graphicsEngine/WGEShaderAnimationCallback.cpp
src/graphicsEngine/WGEShaderAnimationCallback.cpp
+3
-23
src/graphicsEngine/WGEShaderAnimationCallback.h
src/graphicsEngine/WGEShaderAnimationCallback.h
+1
-10
No files found.
src/graphicsEngine/WGEShaderAnimationCallback.cpp
View file @
5dc75fec
...
...
@@ -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
);
}
src/graphicsEngine/WGEShaderAnimationCallback.h
View file @
5dc75fec
...
...
@@ -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.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment