mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-28 03:26:15 +08:00
Scale up the text for large displays
This commit is contained in:
+6
-4
@@ -19,6 +19,7 @@ int main(int argc, char *argv[])
|
|||||||
const char *message = "Hello World!";
|
const char *message = "Hello World!";
|
||||||
int w = 0, h = 0;
|
int w = 0, h = 0;
|
||||||
float x, y;
|
float x, y;
|
||||||
|
const float scale = 4.0f;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
||||||
/* Create the window */
|
/* Create the window */
|
||||||
@@ -39,10 +40,11 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Center the message */
|
/* Center the message and scale it up */
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetRenderOutputSize(renderer, &w, &h);
|
||||||
x = (float)(w - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * SDL_strlen(message)) / 2;
|
SDL_SetRenderScale(renderer, scale, scale);
|
||||||
y = (float)(h - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE) / 2;
|
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 */
|
/* Draw the message */
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
|||||||
Reference in New Issue
Block a user