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
05f9a25
..
988f5d1
100644
(file)
--- a/
src/main.cpp
+++ b/
src/main.cpp
@@
-15,9
+15,9
@@
* 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 <
pg/ticks
.h>
-using namespace
pg
;
+#include <
bear
/debug.h>
+#include <
bear/Timer
.h>
+using namespace
bear
;
#include <iostream>
using std::cout;
#include <iostream>
using std::cout;
@@
-85,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;
@@
-109,9
+111,13
@@
void mainInit()
installSignal();
debug::init();
installSignal();
debug::init();
+
+ s_timer.init();
}
void mainClean()
{
}
void mainClean()
{
+ s_timer.fini();
+
debug::fini();
}
debug::fini();
}
@@
-177,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;
@@
-186,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())
{
@@
-233,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)
@@
-266,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)