//fp_screen.h
class fp_screen{
public:
double fps;
double xx3;
// fp_Screen.cpp
fp_screen::init() // called before everything
{
fps = 0.0;
xx3 = 0.0;
}
bool fp_screen::frame()// called everyframe
{
fps = 1.0 / xx3;
// if i put cout here everything is fine
// in main_frame() things get weird
// im only checking screen.fps not changing value there
r = main_frame();
}
// main.cpp
void main_frame()
{
cout << "fps:" << screen.fps << endl;
}
fps:1.16922e+006 // this will happen 80%
fps:900 // this is how it should be
if i do cout << "fps:" << (int)screen.fps << endl;
somethings number is right like 800 or else
put sometimes its 5423423... something.
You probably printing uninitialized value of fps. Make sure that init is surely called, and better move init code to the constructor or call it from constructor.
// I calculate fps outside here
if( xx5 < gametime )
{
r = main_frame();
xx5 = gametime + xxfps_max;
}
The problem is when im not calling that main_frame
my fps will be 1000000 something.
1.0 / 1000000
will give so many you know, those numbers what come after '.'
Anyway, everything is working fine i guess.
I did not believe that my fps can be so big when i'm not calling main_frame
I guess i should really check out the reason why after calling main_frame fps will be 2000 <