I'm trying to make a simple game. I need to render the text, but I cannot actually use TTF_font cause I am not using any specified font - I've just created my own, little modified one. Anyway I try to render it in this way:
I have class Text which load many font grids. Then I have a method:
[source lang="cpp"]SDL_Surface* Text::Prepare_Text_Image (string txt, int type)[/source]
where obviously txt is the string wanted to get and type is the type of font I'd like to use.
In this function I load wanted font grid to
[source lang="cpp"]SDL_Surface* temp;[/source]
and then I create surface where the text will be rendered:
[source lang="cpp"]SDL_Surface* txt_image = SDL_CreateRGBSurface(SDL_SWSURFACE, spacing*txt.length(), spacing, 32, 0,0,0,0);[/source]
where spacing is just the size of a letter in grid.
Then I blit it like this:
[source lang="cpp"]SDL_BlitSurface(temp, &letter_clip, txt_image, &offset);[/source]
And I end up with an image like this one:
The problem is that even when i use colorkeying then that ugly black background disappers but there is this color around each letter. Of course grid is in PNG file without background. I tried also to fill this txt_image just after creating it and before putting letters onto it with other color and it is ok. I mean there is no black background but red around each letter. So it seems that problem is with creating surface with channel alpha.
I've read dozens of topics but none gave me an answer because either they sent me to non-existing pages or the answer was really too complicated for me. I've even found this one: http://www.gamedev.n...litting-in-sdl/ but I don't understand anything from the answer from Sean Ridenour.
PS: Do you have any idea why around this red ball - the avatar - there is that ugly background? It seems that channel alpha doesn't work there either. I need also to rescale it cause it doesn't appear in proper circle, but nevermind ;)
Thanks for any answers
GortalMember Since 19 Jun 2012
Offline Last Active Jun 22 2012 04:19 PM
- Group Members
- Active Posts 3
- Profile Views 1,060
- Submitted Links 0
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
Gortal hasn't added any contacts yet.
No latest visitors to show