summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-11-25 11:24:14 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-11-25 11:24:14 -0500
commitc2f91a659c126d1fd5ee951bdf58540d9d39fd47 (patch)
treeb63cbf31f19ed2ed01eaf7cf7455033952679546 /main.c
parent4e51199f1103d2d9daa563b63d0e8f22c36fbe8a (diff)
rendering a text buffer
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/main.c b/main.c
index 063f7eb..f2812f5 100644
--- a/main.c
+++ b/main.c
@@ -38,7 +38,8 @@ int main(void) {
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) < 0)
die("%s", SDL_GetError());
- SDL_Window *window = SDL_CreateWindow("ted", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1280, 720, SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL);
+ SDL_Window *window = SDL_CreateWindow("ted", SDL_WINDOWPOS_UNDEFINED,
+ SDL_WINDOWPOS_UNDEFINED, 1280, 720, SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
if (!window)
die("%s", SDL_GetError());
@@ -51,7 +52,7 @@ int main(void) {
SDL_GL_SetSwapInterval(1); // vsync
- Font *font = text_font_load("assets/font.ttf", 24);
+ Font *font = text_font_load("assets/font.ttf", 16);
if (!font) {
die("Couldn't load font: %s", text_get_err());
}
@@ -81,6 +82,7 @@ int main(void) {
int window_width = 0, window_height = 0;
SDL_GetWindowSize(window, &window_width, &window_height);
+ float window_widthf = (float)window_width, window_heightf = (float)window_height;
// set up GL
glEnable(GL_BLEND);
@@ -93,7 +95,8 @@ int main(void) {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1,1,1);
- text_render(font, "hellσ! öθ☺", 50, 50);
+ //text_render(font, "hellσ! öθ☺", 50, 50);
+ text_buffer_render(&text_buffer, font, 50, window_heightf-50, window_widthf-100, window_heightf-100);
if (text_has_err()) {
printf("Text error: %s\n", text_get_err());
break;