Original Post
I seem to be having a little trouble with a static variable...
From my little understanding of static variables, I understand that the memory for a static variable in a function is not de-allocated until its told to. Now lets say I have a function with a static variable in it:
Now whenever I call the function, does the value of blah get reset to 0, or does it retain its last value from the last time the function was called? What I am trying to do is print the updated frames per second out only once per second, not update it every single frame. Now assuming that I have a one second timer that works properly, could I do something like this:
Would the previous suedo-code (assuming that everything works properly) print out the fps from when it was last updated, or would it just print out 0?
Moe''s site
void func(void)
{
static float blah = 0;
//do stuff to blah
}
int Render()
{
static float fps = 0;
if(its time to update the fps)
//update the fps
fps = something;
outputfps(fps);
else
output the fps from the last time it was updated
outputfps(fps);
//return whatever
}