aboutsummaryrefslogtreecommitdiff
path: root/src/text.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-05-22 10:44:49 +0200
committerCharles <sircharlesaze@gmail.com>2020-05-22 10:44:49 +0200
commit6d4c3864e3b742a92e9874f1e4dfe3a9c1565188 (patch)
treea406e7f7d6bdc5210b2133762e39f7bdb396cfff /src/text.c
parentc9098d549d63b5fe18d8c95049ba13a5ae6e9eca (diff)
downloadmandelbrot_cpu-6d4c3864e3b742a92e9874f1e4dfe3a9c1565188.tar.gz
mandelbrot_cpu-6d4c3864e3b742a92e9874f1e4dfe3a9c1565188.tar.bz2
mandelbrot_cpu-6d4c3864e3b742a92e9874f1e4dfe3a9c1565188.zip
Added information (iterations, center, time)
Diffstat (limited to 'src/text.c')
-rw-r--r--src/text.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/text.c b/src/text.c
new file mode 100644
index 0000000..97b3081
--- /dev/null
+++ b/src/text.c
@@ -0,0 +1,34 @@
+#include "mandel.h"
+
+#define MANDEL_TEXT_BUF_SIZE 128
+
+SDL_Texture *text_texture_new(State *state, const char *fmt, ...)
+{
+ SDL_Texture *texture;
+ SDL_Surface *surface;
+ SDL_Color color;
+ char buf[MANDEL_TEXT_BUF_SIZE];
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsnprintf(buf, MANDEL_TEXT_BUF_SIZE, fmt, ap);
+ va_end(ap);
+ color.r = 0;
+ color.g = 0;
+ color.b = 0;
+ color.a = 255;
+ TTF_CALL(surface = TTF_RenderText_Solid(state->font, buf, color));
+ SDL_CALL(texture = SDL_CreateTextureFromSurface(state->renderer, surface));
+ SDL_FreeSurface(surface);
+ return texture;
+}
+
+void text_render(State *state, SDL_Texture *texture, int x, int y, int w, int h)
+{
+ SDL_Rect dst;
+ dst.x = x;
+ dst.y = y;
+ dst.w = w;
+ dst.h = h;
+ SDL_CALL(SDL_RenderCopy(state->renderer, texture, NULL, &dst));
+}