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! 😀

Advertisements

Running Unreal Engine 4 on Ubuntu

March 14, 2015

With Unreal’s latest announcement that they are making the engine available freely to all, I figured I might as well try the IDE client on Ubuntu. These steps should work on any version of Ubuntu, but I’ve only really tested it on Ubuntu 15.04.

This post assumes you know your way around Ubuntu, and have played with Terminals before.

First things first, you still need a Github account and an Unreal account. Why? At the time of this post, the Unreal Github repository is private, so to gain access you must follow Unreal’s requirements to gain access.

  • Make your Github account here (it’s free).
  • Make your Unreal account here (it’s free).

With those setup, you need to link your Unreal account to your Github account before you can access the source code for the Unreal Engine. You do that here, enter your Github username and click save.

Go back to your Github page, and you should see an invitation from Unreal. Accept it. “But wait!” I hear you say, “isn’t the client downloadable for Windows and Mac OSX? Why do we need the source code for Linux?”. In it’s current state, Unreal Engine 4 is not ready for release on Linux (according to the Unreal developers). So, we must make do with the source code for the foreseeable future.

You could use Git to clone (which means download) their source, but it’s just easier if you click Download Zip on the right, and extract it to your desktop once it’s downloaded. Look for the Download Zip button on their page here. Looks like the following. Easy.

Install Required Dependencies

You’ll very likely need quite a few dependencies installed before being able to continue. So, let’s get those installed. Open a terminal, and enter the following:

sudo apt-get install -y mono-gmcs mono-xbuild mono-dmcs libmono-corlib4.0-cil libmono-system-data-datasetextensions4.0-cil
libmono-system-web-extensions4.0-cil libmono-system-management4.0-cil libmono-system-xml-linq4.0-cil cmake dos2unix clang-3.5 xdg-user-dirs libqt4-dev

Setting Up Unreal Engine 4

Alright, we’re set. Let’s get to prepping Unreal Engine 4 to work on Ubuntu. Open a new Terminal, and CD to the directory where you extracted UE4’s source code. For me, that was on the desktop, so my command looked like this:

cd '/home/ismail/Desktop/UnrealEngine'

Once in this directory, we need to run the Setup, so enter this into the Terminal:

./Setup.sh

Go ahead and hit Enter. It may complain that it needs to install extra dependencies (in case we missed any), just type in your password and it will auto-install it for you. It may take a while, since it’s downloading the rest of the UE4 editor files (3GB or more). Once it’s done, let’s run the following:

./GenerateProjectFiles.sh

If you’re successful so far, you should see something like this in your Terminal:

Encountering Errors with Clang

If, after running GenerateProjectFiles, it returns an error like the following:


*** This version of the engine can only be compiled by clang - refusing to register the Linux toolchain.

Generating data for project indexing... 0%
UnrealBuildTool Exception: ERROR: GetPlatformToolChain: No tool chain found for Linux

This means Unreal’s source still can’t be built using Clang 3.5, or it simply can’t find Clang (may not have successfully been installed). Thus, you will need to uninstall Clang 3.5 (if it’s present on your system), and instead install 3.3 as instructed by them here. Personally, for me, Clang-3.5 worked so it should work for you as well. If this error did not occur, you can skip this part! To remove Clang 3.5, enter the following in a new Terminal:

sudo apt-get remove clang-3.5

In Ubuntu 14.04 and above, you should have access to Clang 3.3, 3.4, and 3.5. So, let’s install Clang 3.3. In the same Terminal as just now, enter the following:

sudo apt-get install clang-3.3

Once that’s done, just rerun the GenerateProjectFiles command as shown above (make sure your Terminal is in the same directory as the UE4 folder).

Building the Editor and it’s Components

Time for more commands! Yay! Alright, shouldn’t be long before we get the editor up and running now. Enter the following in the same Terminal as before:

make SlateViewer

That should have been pretty straightfoward and successful. Now, let’s actually build the Editor itself. Note that this part can actually take a seriously long time, that’s normal and ok. In the same Terminal, enter the following:

make ShaderCompileWorker UnrealLightmass UnrealPak UE4Editor

This part WILL TAKE LONG! It took me over 1 hour to compile, and that’s with an Intel i7-4770 3.4GHz CPU. Clang and Mono ate my RAM like crazy, and when compiling certain modules it actually took up 100% of it, which is 8GB of RAM. Do not attempt this if you have less than 8GB of RAM.

Once it’s completed compiling, it should look like this:

Running the Unreal Engine 4 Editor on Ubuntu

Finally! We’ve made it, let’s run this beast. Be prepared, it took me 20 minutes before I was actually able to use the Editor for the first time, since it needs to prepare shaders for first-time use.

Head into your UnrealEngine source folder, enter the Engine folder, enter the Binaries folder, and finally enter the Linux folder (that’s Desktop/UnrealEngine/Engine/Binaries/Linux for me). Scroll down until you see UE4Editor. It should look like this in your window manager:

All you should need to do is double click it to run it! Give it a minute or two before anything appears. The first thing you should see, should look something like this (fullscreen image here):

After 10 minutes for me, the main Editor appeared, but still required another 10 minutes to finish it’s Shader setup.

That’s it! Happy UE4 Linux game developing! Hopefully I haven’t excluded anything important. Please note that at the time of this post, Unreal Engine was at version 4.7.2.


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 😀


Gamemaker and making Children objects run their Event code and their Parent’s Event code

March 3, 2015

Slowly as I move forward with my Gamemaker project, I’ve learned new things along the way. One such thing I’ve learned is that when a Child object makes its own Event, it will override the Parent’s Event code. Sounds like pretty standard procedure, but what happens when you need the Parent’s Event code to run as well?

Let’s say, that there’s a Parent object that never gets instantiated. This Parent object’s sole purpose is to provide code to it’s children for managing mouse over events. Why place this code in the Parent object? We want to remove redundancy. Instead of manually calling this script in all the Children objects, let’s just call it in the Parent object so that all Children objects get it automatically. This Parent object’s code runs in the Step Event. Great, so all Children associated with this Parent object now have that Step Event as well.

Except, the Children objects require other code unique to their instances to run in the Step Event as well. If you’ve gone ahead and added code to the Child object’s Step event, you’ll find that it’s missing functionality when running. Specifically, the Parent’s Step Event code never gets run.

You need both the Parent’s Event code to run, and the Child’s Event code to run. The solution is pretty simple in GameMaker through GML. Just add event_inherited() inside the Child object, and do this before calling the Child’s Event code and you should be golden.

In the above pictures, the Child object will first run the Parent’s Step Event code, and only then will it move onto it’s own Step Event code (which is calling a script in this case). There you go, we have bypassed the Child object’s ability to override the Parent object’s Event code.