summaryrefslogtreecommitdiff
path: root/text.c
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2006-08-04 00:56:19 +0000
committerMatt Turner <mattst88@gmail.com>2006-08-04 00:56:19 +0000
commitf6997ebd1de555916c491dbd603f7a0e9c1d9c58 (patch)
tree23645695bcf2c9ddd154d004dfe09693139ffbf0 /text.c
parentf2837ef813150240c00741018542dc271213ff5c (diff)
git-svn-id: svn://mattst88.com/svn/sdlpong/trunk@2 e27a58fc-241a-0410-afba-9958544cdf14HEADmaster
Diffstat (limited to 'text.c')
-rw-r--r--text.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/text.c b/text.c
new file mode 100644
index 0000000..f221f3d
--- /dev/null
+++ b/text.c
@@ -0,0 +1,30 @@
+#include "SDL.h"
+#include "SDL_ttf.h"
+#include <stdlib.h>
+#include "text.h"
+
+Text_t * CreateText(TTF_Font * Font, const char * text, SDL_Color * components) {
+ Text_t * newtext;
+ newtext = malloc(sizeof(Text_t));
+ newtext->Surface = NULL;
+ UpdateText(newtext, Font, text, components);
+ return newtext;
+}
+
+void UpdateText(Text_t * tobeupdated, TTF_Font * Font, const char * text, SDL_Color * components) {
+ SDL_Surface * Temp = NULL;
+ Temp = TTF_RenderText_Blended(Font, text, *components);
+ if (tobeupdated->Surface) {
+ SDL_FreeSurface(tobeupdated->Surface);
+ }
+ tobeupdated->Surface = SDL_DisplayFormatAlpha(Temp);
+ SDL_FreeSurface(Temp);
+ tobeupdated->Rect.w = tobeupdated->Surface->w;
+ tobeupdated->Rect.h = tobeupdated->Surface->h;
+}
+
+void DeleteText(Text_t * Text) {
+ SDL_FreeSurface(Text->Surface);
+ free(Text);
+}
+