mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-28 15:39:10 +00:00
render: Updates to format-string versions of SDL_RenderDebugText.
- Removes SDL_RenderDebugTextV - Changes SDL_RenderDebugTextF to SDL_RenderDebugTextFormat and tweaks it to work in a world without SDL_RenderDebugTextV. - Tweaked rendering position of formatted text in the example program.
This commit is contained in:
parent
6abebca943
commit
4d4a2786bb
7 changed files with 50 additions and 83 deletions
|
@ -46,6 +46,8 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
|||
/* This function runs once per frame, and is the heart of the program. */
|
||||
SDL_AppResult SDL_AppIterate(void *appstate)
|
||||
{
|
||||
const int charsize = SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE;
|
||||
|
||||
/* as you can see from this, rendering draws over whatever was drawn before it. */
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); /* black, full alpha */
|
||||
SDL_RenderClear(renderer); /* start with a blank canvas. */
|
||||
|
@ -63,7 +65,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
|
|||
SDL_SetRenderScale(renderer, 1.0f, 1.0f);
|
||||
SDL_RenderDebugText(renderer, 64, 350, "This only does ASCII chars. So this laughing emoji won't draw: 🤣");
|
||||
|
||||
SDL_RenderDebugTextF(renderer, 0, 0, "This program has been running for %" SDL_PRIu64 " seconds.", SDL_GetTicks() / 1000);
|
||||
SDL_RenderDebugTextFormat(renderer, (float) ((WINDOW_WIDTH - (charsize * 46)) / 2), 400, "(This program has been running for %" SDL_PRIu64 " seconds.)", SDL_GetTicks() / 1000);
|
||||
|
||||
SDL_RenderPresent(renderer); /* put it all on the screen! */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue