# OpenGL linux opengl display fps (fraps like)

This topic is 2105 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi there,

so I'm writing an fps display tool for linux games using the instanced font rendering lib I wrote.

here's the current code:

https://github.com/Yours3lf/linux_gl_fps/blob/master/main.cpp

my experience so far has been that it works for my own demos/prototypes, but it fails to work on my own engine (I get a SIGBUS on the font draw call, which indicates that there's no context???)

however it did work on a unity game: http://www.desura.com/games/one-late-night

which is a great sign

I'm also having problems with sdl based games like xonotic etc.

the issue is that the MY glXSwapBuffers doesn't really get called for some reason. (I dunno if sdl calls it anytime at all...)

also steam games are 32 bit mostly, so I still need to test them with a 32 bit build.

Is there an alternative way to do buffer swapping on linux besides glx? (something that sdl might use?)

or am I doing something wrong?

EDIT: so I tried to run steam games, turns out you it isn't really that easy to run them from command line, but I did manage to run receiver (unity based again). Plus steam seems to be based on opengl/glx so in every window you get the fps counter

EDIT2: ok I figured out how to launch steam games from steam, you just need to set the launch options for the games like this:

it still doesn't seem to work for some games

EDIT3: soo it seems like the guys at sdl did it a bit curiously (for 1.2.15), they're not calling the glXSwapBuffers function directly, but they're querying it using dlsym, and then they're calling the pointer stored. Of course they're not querying using RTLD_NEXT, but actually opening the .so file, so it's not the correct (actual) function that is getting stored. Sooo I had to override SDL_GL_SwapBuffers too, and it seems to work now. Gotta test some.

EDIT4:

works: world of goo, unity based games, chromium-bsu, neverball, vertigo, amnesia, red eclipse, world-of-padman, xonotic, cube2 sauerbraten, cube2 metalheart, cube2 metalheart2 combat squared

doesn't work probably because of steam overlay: metro last light (it seems to use glxswapbuffers, but I fear that it uses it the same way as SDL does), source-engine based games (they seem to be using SDL)

doesn't work: alien-arena (seems to be using xfree86, like what the hell, this is the third buffer swapping lib... srsly ), penumbra ep1 (probably libstdc++ version mismatch), mars a ridiculous shooter (probably sfml .so version mismatch), overgrowth (a204)

glitchy: stuntrally (the menu works, but in the game the fps is in the car window reflection, which is cool but not what I wanted )

EDIT5: I added a simple outline by drawing the text again one pixel below and to the right

EDIT6: about source games; this is what I get for ldd-ing them:

• 14
• 30
• 9
• 16
• 22