Created
June 29, 2012 02:09
-
-
Save Shaptic/3015229 to your computer and use it in GitHub Desktop.
TTF_Font* vs. MediaManager::Font
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Load the Arial 16pt. font, render some text, | |
* resize the font to 32pt, and render some more text. | |
* | |
* Comparison of TTF_Font* vs my Font class wrapper. | |
*/ | |
const SDL_Color Black = {0, 0, 0}; | |
int main() | |
{ | |
/* Bare TTF_Font */ | |
TTF_Font* Tmp_Font = TTF_OpenFont("C:\Windows\Fonts\Arial.ttf", 16); | |
SDL_Surface* Text_Surface1 = TTF_RenderText(Tmp_Font, "Rendering Text #1!", Black); | |
TTF_CloseFont(Tmp_Font); | |
Tmp_Font = TTF_OpenFont("C:\Windows\Fonts\Arial.ttf", 32); | |
SDL_Surface* Text_Surface2 = TTF_RenderText(Tmp_Font, "Rendering Text #1!", Black); | |
TTF_CloseFont(Tmp_Font); | |
SDL_FreeSurface(Text_Surface1); | |
SDL_FreeSurface(Text_Surface2); | |
/* My wrapper */ | |
MediaManager::Font Arial; | |
Arial.Load("C:\Windows\Fonts\Arial.ttf", 16); | |
SDL_Surface* Text_Surface1 = Arial.RenderText_SDL("Rendering Text #1!\nSupports multi-line!", Black); | |
Arial.Resize(32); | |
SDL_Surface* Text_Surface2 = Arial.RenderText_SDL("Rendering Text #2!", Black); | |
SDL_FreeSurface(Text_Surface1); | |
SDL_FreeSurface(Text_Surface2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment