Skip to content

Commit 21b4335

Browse files
committed
Scale up the text for large displays
1 parent 6bc7e88 commit 21b4335

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/hello.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ int main(int argc, char *argv[])
1919
const char *message = "Hello World!";
2020
int w = 0, h = 0;
2121
float x, y;
22+
const float scale = 4.0f;
2223
bool done = false;
2324

2425
/* Create the window */
@@ -39,10 +40,11 @@ int main(int argc, char *argv[])
3940
}
4041
}
4142

42-
/* Center the message */
43-
SDL_GetWindowSize(window, &w, &h);
44-
x = (float)(w - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * SDL_strlen(message)) / 2;
45-
y = (float)(h - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE) / 2;
43+
/* Center the message and scale it up */
44+
SDL_GetRenderOutputSize(renderer, &w, &h);
45+
SDL_SetRenderScale(renderer, scale, scale);
46+
x = ((w / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * SDL_strlen(message)) / 2;
47+
y = ((h / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE) / 2;
4648

4749
/* Draw the message */
4850
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);

0 commit comments

Comments
 (0)