From 21b433536ae7748dbcb31a6a801c1c36d8ab4fec Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 13 Jan 2025 14:42:36 -0800 Subject: [PATCH] Scale up the text for large displays --- docs/hello.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/hello.c b/docs/hello.c index 1962dd80d5..f513d9318a 100644 --- a/docs/hello.c +++ b/docs/hello.c @@ -19,6 +19,7 @@ int main(int argc, char *argv[]) const char *message = "Hello World!"; int w = 0, h = 0; float x, y; + const float scale = 4.0f; bool done = false; /* Create the window */ @@ -39,10 +40,11 @@ int main(int argc, char *argv[]) } } - /* Center the message */ - SDL_GetWindowSize(window, &w, &h); - x = (float)(w - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * SDL_strlen(message)) / 2; - y = (float)(h - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE) / 2; + /* Center the message and scale it up */ + SDL_GetRenderOutputSize(renderer, &w, &h); + SDL_SetRenderScale(renderer, scale, scale); + x = ((w / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * SDL_strlen(message)) / 2; + y = ((h / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE) / 2; /* Draw the message */ SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);