I''m trying to create a text rendering system in SDL (C++, mingw, Dev-C++) the following way:
- I have a character map which contains all characters I need
- I have a font definition file which contains the coordinates of the characters within the map
1. I (obviously) load the character map (which is in a PNG with alpha channel) into an SDL_Surface this way:
SDL_Surface* surface1 = IMG_Load(filename);
SDL_Surface* fontImage = SDL_DisplayFormatAlpha(surface1);
When I blit this to the screen, it looks perfect, with correct transparencies and everything.
2. I have the function renderText():
SDL_Surface* surface1 = SDL_CreateRGBSurface(SDL_SRCALPHA, width, height, 32,
0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
SDL_Surface* target = SDL_DisplayFormat(surface1);
//For every character...
SDL_BlitSurface(fontImage, &srcrct, target, &dstrct);
The rectangles in the blit command are correct, I''ve checked that.
This is where things get messed up. When I use SDL_DisplayFormat() as in the example, I don''t get an alpha channel, but my text is rendered white on black. If I use SDL_DisplayFormatAlpha(), nothing is rendered at all!
What could be the cause?
Just trying to be helpful.
Just some student from Germany