EDIT: Even if the problem still exists, I could not reproduce it often enough to study it closer. More details at the end of the question.
I started developing the game, and I'm currently writing a base library for it. I use the D programming language with SDL-2 and OpenGL 3 (using Derelict3 bindings), on Linux Mint 13 (Maya). The compiler is DMD64 D Compiler v2.067.1, and every time I rebuild the binary with 'rdmd'.
For rendering (changing) text, I create glyphs on request. Part of the code I use for this:
class Font { ... Texture render(char c) { if(!(c in rendered)) rendered[c] = texture(to!string(c)); return rendered[c]; } Texture texture(string text) { SDL_Color color={255, 255, 255, 255}; auto bitmap = TTF_RenderText_Blended( font, std.string.toStringz(text), color ); if(!bitmap) { throw new TTFError( "TTF_RenderText_Blended: " ~ to!string(TTF_GetError()) ~ ": '" ~ text ~ "'" ); } auto texture = new Texture(bitmap); SDL_FreeSurface(bitmap); return texture; }
The problem is that this is no coincidence. Sometimes this works without problems. When he is unable to display the glyph, it is interesting that he will not be able to display the same glyph again and again. Here is an example when catching the exception that I throw:
... TTF_RenderText_Blended: Text has zero width: '9' TTF_RenderText_Blended: Text has zero width: '6' TTF_RenderText_Blended: Text has zero width: '9' TTF_RenderText_Blended: Text has zero width: '6' TTF_RenderText_Blended: Text has zero width: '9' TTF_RenderText_Blended: Text has zero width: '6' ...
(I print the result on the screen, other numbers are displayed perfectly, with the exception of those few). The TTF_RenderText_Blended number cannot be displayed depending on the start and start, and, as mentioned, from time to time it displays all the numbers.
One detail is that the static lines that I execute before entering the game loop have not yet been rendered, only the individual letters that I use to change the texts.
I almost exclude any ideas and did not find anything related to this problem by searching the Internet. Any ideas for finding solutions are very welcome.
CURRENT SITUATION: I updated the compiler to DMD 2.067.1, and the problem remains (the compilers used so far: 2.066.1, 2.067.1). In general - let, for example, the project family is on github at the moment:
https://github.com/mkoskim/games
The text glyph rendering function is in this file:
https://github.com/mkoskim/games/blob/master/engine/ext/font.d
... and used here:
https://github.com/mkoskim/games/blob/master/engine/ext/gui/label.d
The problem arises mainly / most often in the pacman game (although it is very rare only now):
https://github.com/mkoskim/games/tree/master/testbench/pacman
If you want to try, first read the instructions (in our opinion, quite complete):
https://github.com/mkoskim/games/blob/master/INSTALL
The project was made for 64-bit Linux Mint Maya, and at present it is not user-friendly and portable from the point of view of construction. Pacman is the only demo that (hopefully) works without a game controller. After successfully installing the necessary libraries and tools, you can create it using the command:
games/testbench/pacman$ make default