Hi guys,
I have a form which contains an opengl scene into a panel and I want to show the frames per second.
The code for showing frames per second is correct (copy paste from nehe).
The problem is that even inicializing my timer at 1 miliseconds, the framerate is never higher than 100 fps.
If I put the timer interval to 1 millisecond or 10 milliseconds the frame rate is 100 (and with 1 millisecond it should be higher.)
this->timer1->Enabled = true;
this->timer1->Interval = 1; //in milisegons
this->timer1->Tick += new System::EventHandler(this, timer1_Tick);
The code for fps is this one:
static float framesPerSecond = 0.0f; // This will store our fps
static float lastTime = 0.0f; // This will hold the time from the last frame
static char strFrameRate[50] = {0}; // We will store the string here for the window title
static float frameTime = 0.0f; // This stores the last frames time
float currentTime = timeGetTime() * 0.001f;
// Here we store the elapsed time between the current and last frame,
// then keep the current frame in our static variable for the next frame.
g_FrameInterval = currentTime - frameTime;
frameTime = currentTime;
Show->Render(t);
// Increase the frame counter
++framesPerSecond;
// Now we want to subtract the current time by the last time that was stored
// to see if the time elapsed has been over a second, which means we found our FPS.
if( currentTime - lastTime > 1.0f )
{
// Here we set the lastTime to the currentTime
lastTime = currentTime;
sprintf(strFrameRate, "Current Frames Per Second: %f", framesPerSecond);
this->Text = strFrameRate;
// Reset the frames per second
framesPerSecond = 0;
}
thank you for your time
I have a form which contains an opengl scene into a panel and I want to show the frames per second.
The code for showing frames per second is correct (copy paste from nehe).
The problem is that even inicializing my timer at 1 miliseconds, the framerate is never higher than 100 fps.
If I put the timer interval to 1 millisecond or 10 milliseconds the frame rate is 100 (and with 1 millisecond it should be higher.)
this->timer1->Enabled = true;
this->timer1->Interval = 1; //in milisegons
this->timer1->Tick += new System::EventHandler(this, timer1_Tick);
The code for fps is this one:
static float framesPerSecond = 0.0f; // This will store our fps
static float lastTime = 0.0f; // This will hold the time from the last frame
static char strFrameRate[50] = {0}; // We will store the string here for the window title
static float frameTime = 0.0f; // This stores the last frames time
float currentTime = timeGetTime() * 0.001f;
// Here we store the elapsed time between the current and last frame,
// then keep the current frame in our static variable for the next frame.
g_FrameInterval = currentTime - frameTime;
frameTime = currentTime;
Show->Render(t);
// Increase the frame counter
++framesPerSecond;
// Now we want to subtract the current time by the last time that was stored
// to see if the time elapsed has been over a second, which means we found our FPS.
if( currentTime - lastTime > 1.0f )
{
// Here we set the lastTime to the currentTime
lastTime = currentTime;
sprintf(strFrameRate, "Current Frames Per Second: %f", framesPerSecond);
this->Text = strFrameRate;
// Reset the frames per second
framesPerSecond = 0;
}
thank you for your time