projects
/
physics.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
renamed libpg to libbear
[physics.git]
/
src
/
main.cpp
diff --git
a/src/main.cpp
b/src/main.cpp
index
34aa2ce
..
988f5d1
100644
(file)
--- a/
src/main.cpp
+++ b/
src/main.cpp
@@
-15,7
+15,13
@@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <pg/debug.h>
+#include <bear/debug.h>
+#include <bear/Timer.h>
+using namespace bear;
+
+#include <iostream>
+using std::cout;
+using std::endl;
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <GL/glu.h>
@@
-24,7
+30,6
@@
#include "handleSignal.h"
#include "game.h"
#include "handleSignal.h"
#include "game.h"
-#include "ticks.h"
#include "graphics/graphics.h"
#include "input/inputManager.h"
#include "graphics/graphics.h"
#include "input/inputManager.h"
@@
-80,7
+85,9
@@
static float s_fAccDrawWait = 0;
static int s_iUPS, s_iFPS;
static int s_iUpdateCount, s_iDrawCount;
static int s_iUPS, s_iFPS;
static int s_iUpdateCount, s_iDrawCount;
-static MICRO s_micLastSecond;
+
+static Ticks s_micLastSecond;
+static Timer s_timer;
static const float s_fGameStep = 10;
static const float s_fGameStep = 10;
@@
-104,10
+111,14
@@
void mainInit()
installSignal();
debug::init();
installSignal();
debug::init();
+
+ s_timer.init();
}
void mainClean()
{
}
void mainClean()
{
- debug::clean();
+ s_timer.fini();
+
+ debug::fini();
}
void updatesInit()
}
void updatesInit()
@@
-172,7
+183,7
@@
void run()
void updateFPSCounters()
{
// Check if a second has passed to recalculate UPS and FPS
void updateFPSCounters()
{
// Check if a second has passed to recalculate UPS and FPS
- if (
tickCountMicro
() - s_micLastSecond >= 1000000)
+ if (
s_timer.query
() - s_micLastSecond >= 1000000)
{
s_iUPS = s_iUpdateCount;
s_iFPS = s_iDrawCount;
{
s_iUPS = s_iUpdateCount;
s_iFPS = s_iDrawCount;
@@
-181,7
+192,7
@@
void updateFPSCounters()
s_iUpdateCount -= s_iUPS;
s_iDrawCount -= s_iFPS;
s_iUpdateCount -= s_iUPS;
s_iDrawCount -= s_iFPS;
- s_micLastSecond =
tickCountMicro
();
+ s_micLastSecond =
s_timer.query
();
if(cfg::showFPS())
{
if(cfg::showFPS())
{
@@
-228,18
+239,20
@@
int startUpdateThread(void*)
{
updatesInit();
{
updatesInit();
- s_micLastSecond =
tickCountMicro
();
+ s_micLastSecond =
s_timer.query
();
while(s_bIsRunning)
{
while(s_bIsRunning)
{
- MICRO time = tickCountMicro();
+ Timer timer;
+ timer.init();
handleInput();
update(s_fGameStep);
updateFPSCounters();
handleInput();
update(s_fGameStep);
updateFPSCounters();
- time = tickCountMicro() - time;
+ const Ticks ticks = timer.query();
+ timer.fini();
- float wait = (1000000.0 / s_iTargetUPS - ti
me
);
+ float wait = (1000000.0 / s_iTargetUPS - ti
cks.microseconds()
);
s_fAccUpdateWait += 0 < wait ? wait : 0;
if(s_iMinWaitMicro < s_fAccUpdateWait)
s_fAccUpdateWait += 0 < wait ? wait : 0;
if(s_iMinWaitMicro < s_fAccUpdateWait)
@@
-261,11
+274,13
@@
int startDrawThread(void*)
while(s_bIsRunning)
{
while(s_bIsRunning)
{
- MICRO time = tickCountMicro();
+ Timer timer;
+ timer.init();
draw();
draw();
- time = tickCountMicro() - time;
+ const Ticks ticks = timer.query();
+ timer.fini();
- float wait = (1000000.0 / s_iTargetFPS - ti
me
);
+ float wait = (1000000.0 / s_iTargetFPS - ti
cks.microseconds()
);
s_fAccDrawWait += 0 < wait ? wait : 0;
if(s_iMinWaitMicro < s_fAccDrawWait)
s_fAccDrawWait += 0 < wait ? wait : 0;
if(s_iMinWaitMicro < s_fAccDrawWait)