summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-18 15:28:20 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-18 16:23:05 (EDT)
commitaaa7d7f6b08ecfcc3797683ddad892031f3de8d4 (patch)
tree6c347adb40f7b1d99048057fce0ed1a255fbd2fe /src
parent6178e8fabf13d2e0074f3d9ef5c48b2a77c42c2c (diff)
downloaddodge-balls-aaa7d7f6b08ecfcc3797683ddad892031f3de8d4.zip
dodge-balls-aaa7d7f6b08ecfcc3797683ddad892031f3de8d4.tar.gz
dodge-balls-aaa7d7f6b08ecfcc3797683ddad892031f3de8d4.tar.bz2
main-menu: Render title text
Diffstat (limited to 'src')
-rw-r--r--src/main-menu.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/main-menu.c b/src/main-menu.c
index f3e46bf..01af44e 100644
--- a/src/main-menu.c
+++ b/src/main-menu.c
@@ -24,6 +24,7 @@
#include "main-menu.h"
#include "main.h"
#include "output.h"
+#include "util.h"
void
db_main_menu(void)
@@ -33,6 +34,11 @@ db_main_menu(void)
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Texture *texture;
+ SDL_Color text_color;
+ TTF_Font *font;
+ SDL_Surface *text_surface;
+ SDL_Texture *text_texture;
+ SDL_Rect dest_rect;
struct db_game **games;
int n;
int i;
@@ -44,6 +50,38 @@ db_main_menu(void)
renderer = db_get_renderer();
texture = db_get_texture();
+ /* Render background */
+ SDL_SetRenderDrawColor(renderer, 0x7F, 0x7F, 0x7F, 0xFF);
+ SDL_RenderClear(renderer);
+
+ /* Render title text */
+ text_color.r = 0x00;
+ text_color.g = 0x00;
+ text_color.b = 0xFF;
+ text_color.a = 0xFF;
+ font = TTF_OpenFont(
+ db_strcat(fonts_dir, "/UbuntuTitling-Bold.ttf"), 48);
+ if (font == NULL) {
+ db_err("Failed to open font (%s)", TTF_GetError());
+ return;
+ }
+ text_surface = TTF_RenderText_Blended(font, "Dodge Balls",
+ text_color);
+ if (text_surface == NULL) {
+ db_err("Failed to create surface (%s)", TTF_GetError());
+ return;
+ }
+ text_texture = SDL_CreateTextureFromSurface(renderer, text_surface);
+ if (text_texture == NULL) {
+ db_err("Failed to create texture (%s)", SDL_GetError());
+ return;
+ }
+ dest_rect.x = 16;
+ dest_rect.y = 16;
+ dest_rect.w = text_surface->w;
+ dest_rect.h = text_surface->h;
+ SDL_RenderCopy(renderer, text_texture, NULL, &dest_rect);
+
/* Find games */
n = db_games_find(games_dir, &games);
if (n > 0) {
@@ -56,8 +94,9 @@ db_main_menu(void)
free(games);
}
- SDL_SetRenderDrawColor(renderer, 0x7F, 0x7F, 0x7F, 0xFF);
- SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
SDL_Delay(1000);
+
+ SDL_DestroyTexture(text_texture);
+ SDL_FreeSurface(text_surface);
}