MaartenBaert / ssr

SimpleScreenRecorder, a screen recorder for Linux
http://www.maartenbaert.be/simplescreenrecorder/
GNU General Public License v3.0
2.58k stars 290 forks source link

OpenGL in-game FPS counter #682

Open darealshinji opened 5 years ago

darealshinji commented 5 years ago

For OpenGL, is it possible to display an in-game FPS counter like in Fraps or like the FPS counter option that Steam offers? Without adding it to the capture of course.

MaartenBaert commented 5 years ago

I've considered this, but because of how OpenGL works it is surprisingly difficult to do this without messing up the game itself. OpenGL is a state machine, in order to do anything without affecting the game I need to restore OpenGL back to the same state it was in before I started interfering with it. This includes restoring all the correct shaders, vertex buffers, transformations etc. I'm sure it's possible, but since it's not a high priority I don't really want to spend a lot of time implementing it.

john01dav commented 5 years ago

Would it be easier to just count the number of calls to swap the frame buffer in each second (ie. intercept the X calls to update the window)? This general technique is how I make a FPS counter in my own OpenGl programs, and it shoulden't require modifying OpenGl state at all.

MaartenBaert commented 5 years ago

SSR already does that, this is how the frame rate counter in SSR is able to work for OpenGL games when you're not even recording yet. The hard part is to display the FPS visually in the game itself, without breaking the game.