aboutsummaryrefslogtreecommitdiff
path: root/plot.c
diff options
context:
space:
mode:
Diffstat (limited to 'plot.c')
-rw-r--r--plot.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/plot.c b/plot.c
index 3cf2c0d..7a7a54e 100644
--- a/plot.c
+++ b/plot.c
@@ -1,4 +1,5 @@
#include <SDL.h>
+#include <SDL_ttf.h>
#include "colour.h"
#include "plot.h"
@@ -40,6 +41,30 @@ plot_cell(unsigned int x, unsigned int y, struct colour *c)
}
void
+plot_text(const char *message, TTF_Font *font, SDL_Color color, int x, int y)
+{
+ SDL_Texture *texture = NULL;
+ SDL_Rect dst;
+ dst.x = x;
+ dst.y = y;
+ SDL_Surface *surf = TTF_RenderUTF8_Blended(font, message, color);
+ if (!surf) {
+ printf("Error in TTF_RenderUTF8_Blended\n");
+ return;
+ }
+ texture = SDL_CreateTextureFromSurface(renderer, surf);
+ if (!texture){
+ printf("Error in SDL_CreateTextureFromSurface\n");
+ }
+ SDL_FreeSurface(surf);
+
+ SDL_QueryTexture(texture, NULL, NULL, &dst.w, &dst.h);
+ SDL_RenderCopy(renderer, texture, NULL, &dst);
+
+ SDL_DestroyTexture(texture);
+}
+
+void
plot_clear(void)
{
/* blank out the background with black */