Archive

Archive for September, 2012

Tutorial: Enabling Re-definable Controls in Windows games

September 29, 2012 Leave a comment

In this article we shall take a look at how to make the controls in your C++ game editable by the user. Once again we shall use SimpleTetris as the base example, and as with our implementation of the high score table, we will make use of Boost for serializing (saving) data into a file, and my Simple2D library for rendering the interface (although this part is optional).

Download: Source code (.cpp) | Source code (.h) | Executable

Read more…

Advertisements

The State of the PlayStation Mobile SDK with regards to PlayStation Vita development

September 23, 2012 2 comments

It has now been several months since PlayStation Mobile (formerly PlayStation Suite) was unleashed onto developers in beta form. On 20th September 2012, Sony announced that store deployment will be made available from October 3rd, with a final version of the SDK to be released in November.

So far, I am sorry to report that, in my opinion, the PSM SDK is not in a fit state for production use, particularly for PlayStation Vita development. Far from it. Before I look at the key issues, I want to make it clear that I do understand that PSM is designed as a portable platform to work on all PS Certified devices (which currently includes a range of Xperia Play, Sony Tablet and HTC One devices as well as the Vita), and as such developers wishing to max out the Vita’s hardware potential should ideally be using the official full-blown Vita SDK for games specific to that platform. And that brings me to the core political problem:

Read more…

C++11: About Lambda Functions

September 22, 2012 2 comments

One of my favourite inclusions in C++11 – the latest iteration of C++, formerly known as C++0x – is the ability to create lambda functions. Lambda functions are nothing more than unnamed, essentially anonymous functions that you can define in place of where you would usually use a function name, pointer or reference, and they come in particularly handy in combination with STL, although they are certainly not limited to that use. If you have become used to using Boost.Lambda in your applications, C++11’s lambda functions provide a more convenient syntax while also eliminating your code’s dependency on Boost.Lambda.

As with function pointers and references, lambda functions can be defined as variables, passed to and returned from other functions (including other lambda functions) and so on.

Ground Rules

Let us begin with a simple example comparing the use of C++11 and Boost.Lambda when iterating over a few numbers in an STL vector:

Read more…

Deployment with IExpress: How to turn your MSI file into an EXE

September 22, 2012 2 comments

I have no problem with MSI file downloads. They are as simple as running an EXE. However, for reasons unknown, a lot of people don’t seem to like or understand downloading and running an MSI file; they feel more comfortable with EXEs. Visual Studio Setup projects turn your application into an MSI and a setup.exe file, which is inconvenient for distribution as generally online we want to provide the user with a single file download. Luckily there is a simple and free solution at hand in the guise of a quirky and little-known application included even as late as the Windows 7 base distribution called IExpress. This tool was originally created to enable branded deployments of Internet Explorer 6 (shocking, I know), but we can subvert it quite easily to our needs.
Read more…

How to determine programmatically whether your application and OS are 32 or 64-bit

September 22, 2012 1 comment

First of all, we must clear up a misconception. Some people want to programmatically determine whether the underlying processor in use is 32 or 64 bit. This is a misnomer, as modern Intel and AMD processors can and do run in both 32 and 64 bit modes, in addition there are considerations of cache width, bus width and so on. There is no “true, pure” 64-bit processor, therefore trying to determine this information is non-sensical.

You can, however, determine if you are running a 32 or 64 bit Windows environment, and whether your application is built as a 32-bit or 64-bit executable. Obviously, you should know the latter at compile time, but it can occasionally be able to know at run time too. Here is the code:

Read more…

Categories: Windows Development Tags: , ,

How to determine programmatically if your processor has hyperthreading, SIMD and other processing capabilities with __cpuid

September 22, 2012 1 comment

One of the machine intrinsics in Visual Studio is the __cpuid function, which returns a 4-byte array containing various bit-wise information about the processor hardware capabilities.

While all the gruesome details can be found on MSDN’s __cpuid, __cpuindex page, here is the basic principle:

int cpuinfo[4];
__cpuid(cpuinfo, 1);

bool hasHT = (cpuinfo[3] & (1 << 28)) > 0;

std::cout << "Hyperthreading on CPU is " << (hasHT? "supported" : "not supported") << std::endl;

Read more…

Tutorial: A Modern Approach To Implementing High Score Tables in C++ using STL and Boost

September 22, 2012 4 comments

In this article I shall demonstrate a modern, object-oriented, re-usable technique to adding a local high score table to your C++ Windows games using STL and Boost. I shall use our SimpleTetris game of which this article is a follow-on.

Please note that this is by no means an efficient implementation, it is designed to just show the principle of the technique.

Download: Source code (.cpp) | Source code (.h) | Executable

Read more…

%d bloggers like this: