How to compile and run FRAPIX on Ubuntu

March 25, 2015

In my quest to look for more On-Screen Displays (OSD) for showcasing framerates in OpenGL games on Ubuntu, I’ve come across Frapix.

Now, to get this up and running, we’ll need to build it from source code. It’s not that difficult, but I would put this at intermediate difficulty especially if you’ve never coded or compiled anything before.

Compiling FRAPIX

Download the source code

To start, we’ll need the source code for two things. libimago and frapix.

Just click Download Zip for each. You’ll want to extract both of those onto your Desktop to make things easy.

Alternatively, if you don’t want to you use the Download Zip button but instead want to use git, we could do it like this. The following will clone (download) the source code to whichever directory your Terminal is currently in:

git clone https://github.com/jtsiomb/libimago
git clone https://github.com/jtsiomb/frapix

Installing the dependencies

Before compiling, we need a couple of things installed first. Go ahead and copy/paste this into a Terminal and hit Enter.

sudo apt-get install -y libx11-dev mesa-common-dev libjpeg-dev libpng-dev

Alright, we’re set, let’s first build and install libimago. After that we can build and install frapix.

Building libimago

First, cd into libimago’s folder wherever you extracted it to. For me, that’s on the desktop. This is what it should look like (ismail is my username).

cd '/home/ismail/Desktop/libimago-master'

Now, let’s start building it. Enter the following one-by-one.

./configure
make

This is what it should look like so far:

Installing libimago

Hopefully, no errors turn up here. Time to install it system wide.

sudo make install

Building FRAPIX

With that done, we can now build frapix. Open a new Terminal, and CD into the frapix source code folder wherever you extracted it. For me, that is on the desktop and looks something like this:

cd '/home/ismail/Desktop/frapix-master'

Now, let’s start building it.

make

Installing FRAPIX

sudo make install

That’s it, we’re done! You should now be able to run frapix with any OpenGL application or game and get a suitable fps OSD to display. The cool thing about frapix is that it changes the color of the numbers depending on the background color. If it’s a dark background, the OSD turns to a bright color to constrast it and vice versa.

Running FRAPIX

To test if frapix is working, we can run it with glxgears like so:

frapix glxgears

You should see a neat little OSD with fps numbers on the top right like I do. If you want to run it with Steam games, that’s also possible. Just right click your favourite game in Steam, and add the following to the Launch Options for that game like so:

LD_PRELOAD=/usr/local/lib/libfrapix.so %command%

Click OK and now all you have to do is start the game, it should work! This is what I get in Cities Skylines:

There is one problem though. If you’re on a 32bit OS, you should be fine. However, if you’re on a 64bit OS like me, you’ll end up with the 64bit version of frapix. What does this mean? Any game or OpenGL application that is 32bit-only will not have the frapix OSD appear.

I’m not yet sure how to overcome this problem, as there doesn’t seem to be a way to have both the 32bit version and 64bit version installed at the same time unlike GLXOSD.

Additionally, I have been unable to get any OSD to work in Wine which is the ultimate goal I’m setting out to achieve here. So, sadly, this does not work in Wine.

This should work on any Ubuntu version, but I’ve only really tested it on Ubuntu 15.04 (both 32bit and 64bit versions). I hope this post was helpful to you in one way or another! 😀


Modifying and running VoglPerf on Ubuntu

March 12, 2015

So, we’ve gone and compiled VoglPerf . If you haven’t yet, go here for a quick tutorial. That’s fine and dandy, but how do we go about using it?

Good question. I’m going to assume you have the voglperf folder on your desktop. So, first things first, let’s open a Terminal and enter that directory.

cd '/home/ismail/Desktop/voglperf'

Here’s what it looks like:

Note, change the word ismail to your username! The name ismail here is my username for Ubuntu. To make things even easier, instead of typing the full directory just drag-and-drop your folder into the Terminal. It will auto complete the directory for you.

Alright, time to fire up VoglPerf itself. Enter this into the same Terminal:

sudo -u ismail bin/voglperfrun64

Here’s what it looks like so far:

Note, once again change ismail to your Ubuntu username! On top of that, note that I’m using voglperfrun64 and not voglperfrun32. Which one you use depends on the game you want to run. If the game is a 32bit executable, then run voglperfrun32 instead.

Hitting Enter should now yield the following in the Terminal:

What it’s given you is an IP address. Fret not! Open up your favourite Internet Web Browser (I use Chromium here), and enter the IP at the top.

Sweet! We’ve got VoglPerf up and running. Now, before starting a game, let’s enable fpsshow so that it will show a frame counter in any Steam game we connect it to.

fpsshow on

Ok, time to start a game with VoglPerf. Enter the following (change the numbers to the game you want to start!). Here I’m starting Cities Skylines using VoglPerf:

game start 255710

You might get a long warning message from Steam asking if you want to allow it to launch this way, just click Ok. There’s nothing to worry about.

You’ll know it’s starting up successfully if you see the following appear in the Terminal:

Awesome sauce! We’ve got it running and it’s showing the frames per second on the top left! Well, it’s really kind of tiny, and my gosh red is a bad colour (go here for a fullscreen image to see just how tiny it is).

Modifying VoglPerf

So, let’s go ahead and change that. I’m also going to remove the information at the end of that since I only want the fps numbers. If you follow the rest of this, you will need to recompile VoglPerf as we will be editing the source code 🙂

Head into your voglperf folder. Inside the src folder, open voglperf.c in your favourite text editor. Look for the line that has the following:

// static const char g_MessageBoxFontLatin1[] = "-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1";

Let’s uncomment that code, by removing the // at the beginning. I’m going to change it to the following (more information on this can be found by searching for the X11 Protocol when it comes to fonts):

static const char g_MessageBoxFontLatin1[] = "-*-*-bold-r-normal--0-280-*-*-p-60-iso8859-1";

What I’ve done is increase it’s size and changed it to bold. But, to make it take effect we will need to uncomment the lines following it. It should then look like:

XFontStruct *font_struct = X11_XLoadQueryFont(dpy, g_MessageBoxFontLatin1);
if (font_struct)
{
gcflags |= GCFont;
ctx_vals.font = font_struct->fid;
}

Next, I’m going to change the font color to magenta, as that is the commonly used color besides green for framerate counters. Scroll down a bit further and you should come along these two lines.

ctx_vals.foreground = 0xff0000;
ctx_vals.background = 0x000000;

I’m only going to change the foreground color, so this is what it now looks like:

ctx_vals.foreground = 0xff00ff;
ctx_vals.background = 0x000000;

On to the last part, I want to adjust the position of the text since we’ve resized it to a greater size. Scroll a bit further down, and you should come across the line:

X11_XDrawString(dpy, drawable, glinfo->gc, 10, 20, s_frameinfo.text, (int)strlen(s_frameinfo.text));

This is what it should look like after setting the new position. Note that 20 is the x position on the screen, and 60 is the y position.

X11_XDrawString(dpy, drawable, glinfo->gc, 20, 60, s_frameinfo.text, (int)strlen(s_frameinfo.text));

Lastly, I’m going to remove that unnecessary information appended at the back of the output. You will need to scroll up for this one (or use Ctrl-F and search).

"%.2f fps frames:%u time:%.2fms min:%.2fms max:%.2fms",

Now, make it look like this:

"%.2f fps"

That’s it. Save it and close it. We can now recompile voglperf. CD your Terminal into your voglperf folder. Let’s cleanup first before compiling by running:

make clean

Alright, compile voglperf like normal. More details here for compiling. Running voglperf should now yield a cool fps counter like this:

A fullscreen image of it here. We’re all done and set. This tutorial should work on any Ubuntu version, but I’ve only tested it on 14.04, 14.10 and 15.04. I hope you found this tutorial useful or helpful in one way or another 😀


Compiling VoglPerf on Ubuntu 14.10

January 16, 2015

Well, whilst taking a short break from designing my inventory, weapon, and attribute systems for my little game, I’ve been doing some game benchmark videos pitting Windows against Ubuntu.

In this quest, it usually helps to have a suitable FPS OSD. On Windows, most often it will be MSI Afterburner or FRAPS. On Ubuntu, I have the choice of GLXOSD (preferred), Valve’s VoglPerf and Steam’s own Beta FPS counter.

The issue today is that I can’t seem to get GLXOSD to cleanly inject itself into Dota 2 for some tasty benchmarking. Thus, I have to resort to using VoglPerf, which is really aimed at developers who want to pinpoint where in their game performance is lost, and why. (Take note that VoglPerf only works with games that are on Steam)

I just need the FPS counter.

That said, after downloading VoglPerf from Github here, we can get started:
https://github.com/ValveSoftware/voglperf/archive/0.2.zip

Please note that this guide will work on Ubuntu 14.04 and 15.04 as well. I’ve tested it myself.

I usually just extract it to my desktop, so that’s where all my terminals will point to later when compiling VoglPerf.

First off, you’ll need a couple of dependencies. I recommend installing them one-by-one to see if any issues arise or Ubuntu is unable to find them. To install the following, just simply open a terminal and enter them. Let’s get started on how to compile Voglperf on Ubuntu.

SHORTCUT: INSTALLING THE DEPENDENCIES IN ONE GO

If you can’t be bothered with entering the following one-by-one, and want to get it over with quickly, then just copy this into a terminal, hit Enter, enter your password, and hit y to agree. It should install all required dependencies in one go:

sudo apt-get install build-essential cmake mesa-common-dev libc6-dev-i386 gcc-4.9-multilib g++-4.9-multilib lib32ncurses5-dev

INSTALLING THE DEPENDENCIES ONE-BY-ONE

It’s always best to start with the essentials, and so I usually do this:

sudo apt-get install build-essential

Now, for the required dependencies:

sudo apt-get install cmake

If you get the error regarding

fatal error: GL/glx.h: No such file or directory #include <GL/glx.h>

then you need mesa-common-dev:

sudo apt-get install mesa-common-dev

If you get the error regarding

fatal error: sys/cdefs.h: No such file or directory #include <sys/cdefs.h>

then you need libc6-dev-i386:

sudo apt-get install libc6-dev-i386

If you get the error regarding

fatal error: bits/c++config.h: No such file or directory #include <bits/c++config.h

then you need gcc-4.9-multilib and g++-4.9-multilib:

sudo apt-get install gcc-4.9-multilib g++-4.9-multilib

Moving on, it also looks like you’ll need the following if you’re compiling on a 64bit system and you’re trying to compile VoglPerf64 (although most games on Steam are 32bit binaries, so I believe the most useful version is VoglPerf32 regardless of your system’s architecture):

sudo apt-get install lib32ncurses5-dev

You’ll know if you need the above, when trying to compile and you get the following error:

Linking CXX executable /home/ismail/Desktop/voglperf-0.2/bin/voglperfrun64
/usr/bin/ld: cannot find -ltinfo
collect2: error: ld returned 1 exit status

COMPILING VOGLPERF

Now that you have the required dependencies installed, let’s actually compile VoglPerf so we can use it. Open a new terminal, and CD to your VoglPerf folder. For me that would be:

cd '/home/ismail/Desktop/voglperf-0.2'

Protip: After typing cd and hitting the space bar, simply drag and drop your Voglperf folder into the terminal and it will autocomplete the entire directory path to the folder. Very neat, and seriously saves time.

Once I’m in, I have the choice of doing one of three things. I can either compile both the 32bit version and 64bit version, or I can compile each one one-by-one. I chose to simply compile only the 64bit one so that I may trace any problems easily. So, to compile both, all you would do is:

make

If you’re looking to just compile the 32bit version, then do the following in the same terminal:

make voglperf32

For the 64bit version, do the following in the same terminal:

make voglperf64

If you compiled successfully, it should look something like the following:

Now, please take note that after you’ve compiled a build, that folder will be in the voglperf folder. You’re building to the same folder you’re taking the source from. What this means is that, if you want to start fresh, or have made changes to the code, I recommend deleting the build folder (aptly named build32 for the 32bit version, and build64 for the 64bit version) before compiling a new build.

After all that compiling, you can find what you’ve built in the bin folder inside the voglperf folder. After all, what you’ll be running is the executable (which should be voglperfrun32 or voglperfrun64). You should have one of either of these, or both like I do:

Also, if you feel uncomfortable using the terminal, for the most part you can make use of the Ubuntu Software Center to install the dependencies. For example:

Please note, that while my Ubuntu system was a fresh install, it may be possible that I’ve installed other required libraries or dependencies previously that I have forgotten about or unknowingly done so. If you find any dependencies not listed here, please feel free to comment and add them so that others may know what they are and how to resolve them.