mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-06 01:46:25 +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:
@@ -149,15 +149,29 @@ static void SDL_InitDynamicAPI(void);
|
||||
va_end(ap); \
|
||||
return result; \
|
||||
} \
|
||||
_static bool SDLCALL SDL_RenderDebugTextF##name(SDL_Renderer *renderer, float x, float y, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
|
||||
_static bool SDLCALL SDL_RenderDebugTextFormat##name(SDL_Renderer *renderer, float x, float y, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
|
||||
{ \
|
||||
bool result; \
|
||||
char buf[128], *str = buf; \
|
||||
int result; \
|
||||
va_list ap; \
|
||||
initcall; \
|
||||
va_start(ap, fmt); \
|
||||
result = jump_table.SDL_RenderDebugTextV(renderer, x, y, fmt, ap); \
|
||||
result = jump_table.SDL_vsnprintf(buf, sizeof(buf), fmt, ap); \
|
||||
va_end(ap); \
|
||||
return result; \
|
||||
if (result >= 0 && (size_t)result >= sizeof(buf)) { \
|
||||
str = NULL; \
|
||||
va_start(ap, fmt); \
|
||||
result = jump_table.SDL_vasprintf(&str, fmt, ap); \
|
||||
va_end(ap); \
|
||||
} \
|
||||
bool retval = false; \
|
||||
if (result >= 0) { \
|
||||
retval = jump_table.SDL_RenderDebugTextFormat(renderer, x, y, "%s", str); \
|
||||
} \
|
||||
if (str != buf) { \
|
||||
jump_table.SDL_free(str); \
|
||||
} \
|
||||
return retval; \
|
||||
} \
|
||||
_static void SDLCALL SDL_Log##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
|
||||
{ \
|
||||
|
Reference in New Issue
Block a user