mElite
1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
mElite
FrameCounter.cpp
Go to the documentation of this file.
1
6
#include "
GlobalGL.h
"
7
#include "
FrameCounter.h
"
8
10
13
FrameCounter::FrameCounter
(
void
) {
14
frames = 0;
15
//start = glutGet( GLUT_ELAPSED_TIME );
16
fps = 0;
17
m_frameStart = start =
getTime
();
18
m_lastFrameTime = 0;
19
}
20
24
FrameCounter::~FrameCounter
(
void
) {
25
26
}
27
29
32
int
FrameCounter::getFrameRateAverage
(
void
) {
33
return
fps;
34
}
35
36
long
FrameCounter::getFrameStart
(
void
) {
37
return
m_frameStart;
38
}
39
41
44
float
FrameCounter::getFrameTimeAverage
(
void
) {
45
return
1000.0/
getFrameRateAverage
();
46
}
47
51
long
FrameCounter::getFrameTimeCurrent
(
void
) {
52
long
now =
getTime
();
53
long
passed =
getFrameStart
();
54
return
now - passed;
55
}
56
60
long
FrameCounter::getFrameTimeLast
(
void
) {
61
return
m_lastFrameTime;
62
}
63
64
long
FrameCounter::getTime
(
void
) {
65
return
glutGet( GLUT_ELAPSED_TIME );
66
}
67
69
72
void
FrameCounter::newFrame
(
void
) {
73
long
now =
getTime
();
74
m_lastFrameTime = now - m_frameStart;
75
m_frameStart = now;
76
frames++;
77
}
78
80
84
void
FrameCounter::update
(
void
) {
85
long
now =
getTime
();
86
long
dTime = now - start;
87
88
if
( dTime > 1000 ) {
89
start = now;
90
fps = (long)(1e3 * (
double
)frames/(double) dTime);
91
frames = 0;
92
}
93
}
Generated on Tue Oct 2 2012 14:38:37 for mElite by
1.8.2