Update 70

A lot of profiling and refactoring have been done last week. I have also implemented some dialogs for the last level. I am trying to optimize the allocation of vectors using the function reserve. But first I have searched all over the internet to find the best free profiler. The profiler packed with visual studio 2015 seem to give the most readable result, microProfiler is also a nice one because you can profile in real time.  CodeXL doesn’t have support for intel processor and the interface is not so good.

The profiler packed with visual studio 2015 seem to give the most readable result, microProfiler is also a nice one because you can profile in real time.  CodeXL doesn’t have support for intel processor and the interface is not so good.

I am trying to optimize the text rendering in the game because sometimes when there is a shader applied the framerate drop from 60 fps to 15 fps. Maybe this is only due to the shader and I need to find a shader profiler.

For Christmas, I have received a new graphic tablet: Wacom Intuos medium pro since the small bamboo gives me wrist pain after working several hours on a piece. This tablet is better is every way possible, interface, precision, size, quality. The only downside is the price, like every other Wacom products you need to spend hundreds of dollars to have something good. I think this tablet have the best size and quality for the price since Cintiq are overpriced.

They are other brands like Huion, Ugee, Yiynova, the problem is Wacom have so many patents and years on experience on tablets it’s very difficult for new competitors to achieve the quality. Only maybe a very big corporation like Apple, Microsoft, Samsung can pull off a quality similar. And there are compatibilities problems with drivers of Wacom and other brands.

Only maybe a very big corporation like Apple, Microsoft, Samsung can pull off a quality similar. And there are compatibilities problems with drivers of Wacom and other brands. This tablet is also a best seller on amazon after the cheapest tablet of Wacom.

Update 69

The level 4 is finished, I am now working on the last level. This level is the ending of the game so it’s very short gameplay wise and they are a lot of dialogs.

Last week I have done an explosion with the particles system, this explosion has 100000 particles. At first, 100000 was too much to handle for the particle system.

After a lot of profiling, the engine I have found some interesting things:

rand() is too slow, so replace it with a xorshift generator, in the game engine I use xorshit128:

static uint32_t xor128x = 123456789;
static uint32_t xor128y = 362436069;
static uint32_t xor128z = 521288629;
static uint32_t xor128w = 88675123;
inline uint32_t xor128(void) {
uint32_t t;
t = xor128x ^ (xor128x << 11);
xor128x = xor128y; 
xor128y = xor128z; xor128z = xor128w;
return xor128w = xor128w ^ (xor128w >> 19) ^ (t ^ (t >> 8));
}

Do not use std::vector to store the particles, push_back() and erase(iterator) are too slow. If you do you will see a lot CPU spent on memmove. A dynamically allocated array is way faster, only the initialization take time.

Use batching to reduce the number of draw call, with SDL_gpu the best way is to draw a lot of primitives is to use GPU_TriangleBatch. It adds a lot of code but you can’t have something faster than that.

unsigned short indices[3] = {0, 1, 2};  // These are references to the vertex array's vertices, 3 for a triangle
float values[8 * 3];  // Each vertex will need x, y, s, t, r, g, b, a (8 floats per vertex)
values[0] = x1;  // Position
values[1] = y1;
values[2] = s1;  // Texture coordinates (normalized)
values[3] = t1;
values[4] = r1;  // Color (normalized)
values[5] = g1;
values[6] = b1;
values[7] = a1;
values[8] = x2;  // Position
values[9] = y2;
values[10] = s2;  // Texture coordinates (normalized)
values[11] = t2;
values[12] = r2;  // Color (normalized)
values[13] = g2;
values[14] = b2;
values[15] = a2;
values[16] = x3;  // Position
values[17] = y3;
values[18] = s3;  // Texture coordinates (normalized)
values[19] = t3;
values[20] = r3;  // Color (normalized)
values[21] = g3;
values[22] = b3;
values[23] = a3;
GPU_TriangleBatch(image, target, 3, values, num_indices, indices, GPU_BATCH_XY_ST_RGBA);

With SDL you will need to use OpenGL VBO to achieve efficient batching.

Update 68

This week I needed to make some smoke  for an important object in the game so I have implemented a simple particle system. I tried to find libraries for a system particle but surprisingly there is very little free libraries still alive.  There are expensive middlewares like popcornfx and fork particle. At first, I was creating a rendered compatible with SDL_gpu for the library spark engine but after multiples unsuccessful tries I decided to make one myself, something very simple and basic.

After this key item, I can start polishing the last level.

Update 67

Lately, I have been implementing the secrets in the game but testing became a pain because I need to go to multiple maps through the game. Basically, I need to go through the whole game just to test if every secret make sense. To help me with the testing I have been trying to add a GUI menu for debugging purpose, but there is no really good GUI it seems.

I have been testing :
CEGUI 0.8.7 : The tutorial are mostly written for the previous version 0.7, a lot of things are missing. I have failed to run the examples, the library is quite big. I need to waste a lot of time on forums or adapting examples just to get something simple basic working.  A lot of dependencies are required.

kiss_sdl : Very lightweight library where the rendering is performed by SDL and SDL_image. So I need to modify the library to use SDL_gpu, quite a bit of work. Developed by one person, so it could be buggy.

nanogui-sdl : The implementation have some problem on windows, static linking is creating conflict. This is a port of another library : nanogui.

After all these research I decided to simply do a small command line tool myself something very small, where I can warp, get an object and change a variable.

cmd2