projects
/
physics.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d893cce
)
added rolling times
author
Patrik Gornicz
<Gornicz.P@gmail.com>
Fri, 22 Aug 2008 01:32:16 +0000
(21:32 -0400)
committer
Patrik Gornicz
<Gornicz.P@gmail.com>
Fri, 22 Aug 2008 01:32:16 +0000
(21:32 -0400)
src/main.cpp
patch
|
blob
|
blame
|
history
diff --git
a/src/main.cpp
b/src/main.cpp
index
d8ca3e1
..
228c238
100644
(file)
--- a/
src/main.cpp
+++ b/
src/main.cpp
@@
-61,7
+61,7
@@
bool is_Running;
* draw_Count := counts this seconds draws
* last_Second := stores the time of the last second, used for ups and fps
*/
* draw_Count := counts this seconds draws
* last_Second := stores the time of the last second, used for ups and fps
*/
-int target_UPS =
25
0;
+int target_UPS =
10
0;
long int last_Block_Update;
float update_Sum = 0;
long int last_Block_Update;
float update_Sum = 0;
@@
-70,6
+70,16
@@
int update_Count, draw_Count;
long int last_Second;
long int last_Second;
+float target_time_steps_per_second = 100;
+
+
+// experiment with rolling averages
+float rUpdate = 100;
+float rDraw = 100;
+float rRun = 100;
+float num = 10;
+
+
/// ***** MAIN Method *****
int main()
{
/// ***** MAIN Method *****
int main()
{
@@
-123,9
+133,17
@@
void run()
while(is_Running)
{
while(is_Running)
{
- blockUpdate();
- updateFPSCounters();
- draw();
+ long int time;
+
+ time = tickCountMicro();
+ blockUpdate();
+ updateFPSCounters();
+ draw();
+ time = tickCountMicro() - time;
+
+ rRun = (rRun * (num-1) + time) / num;
+
+ cout << "rR:\t" << rRun << endl;
}
}
}
}
@@
-133,6
+151,8
@@
void blockUpdate()
{
long int start = tickCountMicro();
{
long int start = tickCountMicro();
+ cout << "Block" << endl;
+
// Calculate the updates that should be run for the next draw
update_Sum += (start - last_Block_Update) / (1000000 / (float)target_UPS);
// Calculate the updates that should be run for the next draw
update_Sum += (start - last_Block_Update) / (1000000 / (float)target_UPS);
@@
-150,7
+170,7
@@
void blockUpdate()
for (int i = 1; i <= iupdate_sum; i++)
{
handleInput();
for (int i = 1; i <= iupdate_sum; i++)
{
handleInput();
- update(time_step
*i
/ 1000);
+ update(time_step / 1000);
}
// remove the updates that where run from the sum
update_Sum -= iupdate_sum;
}
// remove the updates that where run from the sum
update_Sum -= iupdate_sum;
@@
-189,18
+209,37
@@
void handleInput()
void update(float time_step)
{
void update(float time_step)
{
+ long int time;
+
update_Count++;
update_Count++;
- game::update(time_step);
+ time = tickCountMicro();
+ game::update(time_step);
+ time = tickCountMicro() - time;
+
+ rUpdate = (rUpdate * (num-1) + time) / num;
+
+ cout << "ru:\t" << rUpdate << endl;
+ cout << "ts:\t" << time_step << endl;
}
void draw()
{
}
void draw()
{
+ long int time;
+
draw_Count++;
draw_Count++;
- game::draw();
+ time = tickCountMicro();
+ game::draw();
+
+ SDL_GL_SwapBuffers();
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ //SDL_Delay(50);
+ time = tickCountMicro() - time;
-
SDL_GL_SwapBuffers()
;
+
rDraw = (rDraw*(num-1) + time) /num
;
-
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
;
+
cout << "rd:\t" << rDraw << endl
;
}
}