How to get the frame rate using wxGLCanvas library
How to get the frame rate using wxGLCanvas library
Hi, I am new learner. I want to know about to How to get the frame rate using wxGLCanvas for linux environment? Have you any idea and code about it? Please help..
Re: How to get the frame rate using wxGLCanvas library
Use wxGetLocalTimeMillis to measure the time difference between two paint events. Then calculate FPS based on that.
https://docs.wxwidgets.org/trunk/group_ ... cd81ae09da
Alternatively, count frames over a longer period of time and calculate based on that.
https://docs.wxwidgets.org/trunk/group_ ... cd81ae09da
Alternatively, count frames over a longer period of time and calculate based on that.
Use the source, Luke!
Re: How to get the frame rate using wxGLCanvas library
Can you explain using paint event how to work with video frame rate count
Re: How to get the frame rate using wxGLCanvas library
Supposed you have a paint event handler, do it like this:
This requires you to have some code that redraws the content permanently, e.g. by using one of the methods described in the wiki: https://wiki.wxwidgets.org/Making_a_render_loop
Code: Select all
void SomeClass::OnPaint(wxPaintEvent &event)
{
static wxLongLong s_lastTime = -1;
wxLongLong actTime = ::wxGetLocalTimeMillis();
double fps = 0.0f;
if( s_lastTime != -1 ) {
fps = 1000.0f / (actTime - s_lastTime).ToDouble();
}
s_lastTime = actTime;
// your other rendering code
// draw FPS on top
};
Use the source, Luke!