9 Sep

This might save some people from losing a few hours over a seemingly simple issue. When you update the Google Play Services SDK, and possibly the Android API, it might happen that your application suddenly crashes when calling isGooglePlayServicesAvailable with a NoClassDefFoundError.

17 Aug

Although HTTPS is the default protocol to secure websites and web services, it seems that it is often badly understood. These are two points which often crop up in forums.

18 May

Drop the last column

A 2D transform is typically shown as a 3×3 augmented matrix. However the last column (or row depending which order you use) of an augmented matrix is always 0 0 1, so we don’t need to store it. We only store a 2×3 matrix.

$\begin{bmatrix} a & b \\ c & d \\ e & f \end{bmatrix}$

The 2 upper rows will contain the rotation, scale and shear factors, while the lower row contains the translation.

Using the NDK and JNI to build android applications

25 Aug

When writing applications for android in java, there are often parts that you expected to perform better. It’s not always the algorithm that is to blame. Java has its limits. Even with a JIT compiler it will have more runtime overhead, and a garbage collector will run at times you don’t want it to. We can solve this by moving demanding pieces of our code to C, C++ or assembler.  Continue reading

Optimization tip: reduce the amount of code to execute

21 Jul

Reducing the amount of code to execute is not always the work of the compiler, the person writing the code has to be conscious of how the code will end up in instructions in order to obtain optimized binary code.

Optimization tip: don’t use sqrt when comparing distances

7 Jul

When comparing distances, whether it be for collision detection in games or drawing circles or discs (like in this recent Geeks3D post) I often see people using sqrt when they are comparing distances. This sqrt is not needed and only wastes CPU or GPU time.

Memory management in C++ Part 2

29 Jun

While part 1 focussed on avoiding memory leaks, this post will look at memory strategies which optimize speed. While in many cases a normal allocation/reallocation/deallocation scheme works well, there are several instances where this can slow down software considerably. In these cases one of the following strategies can help to improve the performance of your application.