Thomas Sampson

Leave a comment

Success @ Games Republic 2012

Today’s Games Republic 2012 event, held at the University of Bradford, was incredibly rewarding for our team. The day was spent exhibiting our PSP Minis title BounceBack (along with our SteelEngine PSP game engine) to both students and industry professionals, and of course, the judges! We received some excellent feedback and were very humbled to be awarded the following three prizes…

 1st Prize – Best Team – Awarded by Rockstar Leeds
1st Prize – Best Game Technology – Awarded by Four Door Lemon
1st Prize – Best Game Design – Awarded by Sumo Digital

Many Photos were also taken at the event. BounceBack will be available for download on the Playstation Store for both PSP and Playstation 3, Summer 2012.

Leave a comment

Installing .deb packages without Ubuntu Software Centre

If like me, you attempt to avoid Ubuntu Software Centre at all costs (due to it’s often slow and clunky nature) you can easily install a downloaded Debian package from the terminal as follows:

sudo dpkg -i mypackage.deb

Packages can also be removed in a similar fashion if you know the package name:

sudo dpkg -r mypackage

Leave a comment

Preventing Multiple Process Instances In C++

Here is a quick C++ class I knocked up earlier this week which can be used to ensure that only a single instance of your application is running at any given time, using a system-wide mutex object along with a unique process identifier to prevent concurrent execution. The implementation provided is Windows only but could easily be adapted for other platforms using pthread_mutex_trylock.

ProcessInstance Class

#include <windows.h>
#include <string>

class ProcessInstance
	ProcessInstance(const std::string& processIdentifier)
		: m_bIsAlreadyRunning(false), m_hProcessInstanceLock(0)
		m_hProcessInstanceLock = ::CreateMutex(0, true, processIdentifier.c_str());
		m_bIsAlreadyRunning = (::GetLastError() == ERROR_ALREADY_EXISTS);


	bool IsAlreadyRunning() const
		return m_bIsAlreadyRunning;

	bool m_bIsAlreadyRunning;
	HANDLE m_hProcessInstanceLock;


ProcessInstance gProcess("my_process_guid_here");
int main(int argc, char* argv[])
		return 0;

Leave a comment

Games Britannia 2013

This year my friend and colleague Griffin Warner and I were asked to prepare and present game development workshops at Games Britannia Festival 2013. Games Britannia is a fantastic event which aims to bring together school children, educators, parents and industry professionals to discuss, practice and celebrate video game development and talent in the local region.

After attending Games Britannia 2012 to showcase BounceBack, I was excited to be invited back to carry out workshops and make a more substantial contribution to the event which had proven so successful the previous year. We were given the brief of putting together a two hour workshop, aimed at secondary school students of all ages, many of which with little/no prior games development knowledge or experience. At this point Griff and I had no previous experience teaching or delivering workshops, and found that planning the content and pacing of the workshops was particularly challenging.

After some deliberation we came up with the concept of a small RPG game named “Outbreak” which we would develop ourselves ahead of the workshops, which would intentionally have key components and section of logic missing from the game. The purpose of the workshops would then be to flesh out the game by discussing and implementing the missing components via a series of lecture slides and hands-on sessions. We chose to use Game Maker to develop the workshop resources, which proved highly beneficial as it allowed us to easily prototype the game in a matter of weeks. Choosing Game Maker also provided a simple graphical interface which was used during the workshop to demonstrate and implement the missing functionality, without having the students write a single line of code (although we did make sure to discuss the limitations of this approach and stress the importance of traditional programming techniques!).

We both worked hard preparing the workshop material in the weeks prior to the event. I implemented the basic skeleton for the game and implemented all of the core functionality, whilst Griff put together some excellent artwork and animation sequences for the game world and characters, which was later added to the skeleton to form the final workshop resource. At this point we were very privileged to be invited to Meadowhead  School in Sheffield to trial the workshop during an after school class, with a bunch of students who had kindly volunteered their time to act as guinea pigs for the Games Britannia sessions. After a few technical setbacks the workshop trial went surprisingly well and gave us the opportunity to tweak the difficulty levels and timings, and also address some of the feedback we received from the students.

The same week we were informed that our workshops had sold out and that we were lucky enough to have been sponsored by YoYo Games who agreed to provide free Game Maker Studio licenses for the event. With access to Game Maker Studio in mind, and particularly it’s ability to export to other platforms, we added a section to the end of the workshop which would allow the students to run their game on the Android tablets provided, at the flick of a switch!

Ultimately the workshops held at Games Britannia appeared well received by the students and there was definitely a sense of excitement and creativity during the sessions. Delivering the workshops (especially multiple times back-to-back over the course of two days) was harder work than anticipated but became easier and felt more natural as each session went by. The Android play-testing went down a storm, and many students were desperate to get a copy of the game to take home and install on their own devices. Personally I found it very rewarding getting the chance to speak with the kids who took part and particularly the select few who showed a great passion and enthusiasm towards game development and programming at such a young age, many of which reminded me of myself when I was in school. It was great having the opportunity to give advice I was never given, on how best to get into games development, the skills required, and the importance of communication skills and an autonomous approach towards learning new skills.

On behalf of Griff and myself I would like to thank everyone involved in Games Britannia 2013, particularly Jacob Habgood for inviting us to take part, Joanne Hewitt from Meadowhead school for allowing us to visit and trial our session, and YoYo Games for sponsoring the festival! Below are some photos taken from the event;

Leave a comment

Unblock The Pirate Bay

For some reason over the last year or so it seems that some internet service providers in the U.K have deemed themselves responsible for censoring which parts of the internet we can and can’t see.

Luckily this nonsense can be easily circumvented in most cases. The following extension for chrome fixes denied access to torrent sites such as the pirate bay, isohunt, kat etc (all of which index many legitimate torrents) by redirecting to one of a number of mirror sites. It appeared to work seamlessly first time for me on a number of blocked sites.

Chrome extension: Unblock The Pirate Bay

On a final note; It is well known that YouTube indexes and hosts a much larger volume of copyrighted material than many torrent sites even link to! I doubt we will be seeing YouTube censored by ISPs anytime soon……

Leave a comment

Silencing ‘Unused Variable’ Warnings

Warnings generated by C++ compilers which inform you that your code has ‘unused’ or ‘unreferenced’ variables in undoubtedly a good thing. Warnings such as this usually suggest that a variable can be removed (perhaps it was a debug or temporary variable a frantic coder neglected to remove) or perhaps a variable which is not being properly assigned or accessed due to a typo or re-factoring cock-up. However there are instances where this kind of warning can prove troublesome, especially when warnings are treated as errors (a discipline I strongly advocate).

More specifically, this kind of warning can become difficult to cure within code heavily plagued with pre-processor conditions (either inlined or included via some ‘clever’ macro) which control which lines or sections of code are stripped and included under a projects often plentiful build configurations. Such mechanisms can prove very powerful, perhaps to strip all debug code from a particular build, or include specific code segments per platform. However code littered with nested conditional sections such as this often become messy and difficult to manage. As a result, some variables (which are in-fact referenced multiple times within the file) become un-referenced when building with a particular build configuration.

A Very Basic Example

Within the following code the msg variable is used within debug builds but becomes obsolete when carrying any non-debug build, yielding the compiler warning in question:

#include <stdio.h>

#if defined(_DEBUG)
#define DEBUG_PRINT( x ) printf((x));
#define DEBUG_PRINT( x )

void main()
	const char* msg = "Some Debug Message";

The Solution?

In a case as simple as the above it might be tempting to checkout the DEBUG_PRINT macro and upon discovering that this macro only uses its parameter when _DEBUG is defined, nest the declaration of the msg variable within an identical conditional section. This will work perfectly in such a contrived scenario but when working with larger more complex codebases this approach can involve trawling through numerous nested macros and expansions, and may only fix the problem under a particular build configuration. Perhaps a better approach is to wrap the offending variable with the following macro which tricks the compiler into having used the variable under all build configurations (provided the macro is included within all build configurations of course).

#include <stdio.h>
#define ALWAYS_USE( x ) do { } while( &(x) != &(x) )

#if defined(_DEBUG)
#define DEBUG_PRINT( x )...

void main()
	const char* msg = "Some Debug Message"; ALWAYS_USE(msg);

The ALWAYS_USE macro shown above will make the compiler believe that the msg variable is always being used, however it’s contribution to the final executable should be non-existent when compiler optimisations are enabled (or at worst generate a NOP instruction on some compilers).

MSVC Generated Assembly NDEBUG (/O2)

void main()
    00F01000  xor   eax,eax 
    00F01002  ret

Leave a comment

View Frustum Notes

The purpose of this blog post is to jot down a few handy tips and tricks worth remembering working with view frustums, ranging from the blatantly obvious to the more obscure. I don’t spend as much time reviewing these posts as I would like, so as ever, please feel free to comment with any corrections or related tips.

Inverse View Matrix

A cameras view matrix is most often represented as a homogeneous 4×4 matrix used to shift bases, transforming points from world space, to the camera’s own three-dimensional co-ordinate system (‘camera space’ or ‘view space’). However a cameras inverse view matrix can also have it’s uses. A camera’s inverse matrix represents the position and orientation of the camera it’s self within the world and can therefore prove useful in the following scenarios:

  • When rendering game cameras within the world, perhaps useful when debugging or writing tools which deal with the positioning/manipulation of multiple cameras
  • Extracting the camera’s translation and orientation when these values are not immediately available/accessible

Finding View Frustum Vertices

Sometimes it can be useful to find the world space vertices which define the corners of the view frustum, perhaps to render the frustum, or to find the distance to a particular point or edge. Given the position, orientation, aspect ratio and FOV of a camera it is possible to manually calculate the frustums corners, however a much more elegant approach is at hand.

Start by setting up the vertices of a cube with it’s local extents representing the clip-space of your graphics pipeline (OpenGL uses [-1,-1,-1]→[1,1,1] for clip-space whereas DirectX uses [-1,-1,0]→[1,1,1]). Next, transform this ‘clip space cube’ by the camera’s inverse projection matrix. This will reveal the corners of the view frustum in view space. Further transforming these points by the camera’s inverse view matrix will yield the world-space vertices representing the corners of the view frustum.

Caching View Frustum Data

This one may seem pretty obvious, but calculating data such as frustum planes, corners and angles can be computationally expensive and need only be carried out whenever the camera is moved or re-oriented. If your camera class has Set methods for properties such as position, lookat, FOV etc, it may be wise to check that the new value is unique before setting, re-calculating or storing any new data.

Storing View Frustum Planes / Normals

As planes can be represented using a pair of vectors (position and a unit normal) or better still in a single vector (ax + by + cz + d = 0), it might seem sensible to store a vector or vector pair per frustum plane. It is worth considering however that view frustums are almost always symmetrical and therefore calculating and storing only the left/top plane may be beneficial in some cases. When the right/bottom planes are required they can be generated on the fly by reflecting the left/top planes about the cameras local axis. If the view frustum is always parallel to a world axis this fact can be exploited by storing only the left/top frustum planes and simply inverting the appropriate component of the point/normal vectors to perform the reflection. Frustum planes can also be extracted directly from the camera’s view/projection matrix on the fly, see Fabian “ryg” Giesen’s excellent blog post for more information.


MSDN – Viewports and Clipping (Direct3D 9)
Frustum planes from the projection matrix
OpenGL Transformations


Get every new post delivered to your Inbox.

Join 91 other followers