blob: 8a093ea0eb3f708c21318fa319b80ed44c885240 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <SDL3/SDL_render.h>
#include <saffron.h>
#include <SDL3/SDL.h>
#include <SDL3_ttf/SDL_ttf.h>
#include <stdlib.h>
static void saffron_text_draw(SaffronWidget* widget, SDL_Renderer* renderer) {
SaffronText* text = (SaffronText*)widget;
if (!text->text || !text->font) return;
SDL_Surface* surface = TTF_RenderText_Blended(text->font, text->text, 0, text->color);
if (!surface) return;
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_FRect dest = {widget->x, widget->y, (float)surface->w, (float)surface->h};
SDL_RenderTexture(renderer, texture, NULL, &dest);
SDL_DestroyTexture(texture);
SDL_DestroySurface(surface);
}
SaffronText* saffron_text_new(const char* text, int font_size, SDL_Color color) {
SaffronText* text_widget = malloc(sizeof(SaffronText));
if (!text_widget) return NULL;
saffron_widget_init((SaffronWidget*)text_widget);
// todo actually do stuff
// and return something
// im tired ill do this later
}
|