mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-05 09:26: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, ...) \
|
||||
{ \
|
||||
|
@@ -1207,8 +1207,7 @@ SDL3_0.0.0 {
|
||||
SDL_SetGPUAllowedFramesInFlight;
|
||||
SDL_RenderTextureAffine;
|
||||
SDL_WaitAndAcquireGPUSwapchainTexture;
|
||||
SDL_RenderDebugTextF;
|
||||
SDL_RenderDebugTextV;
|
||||
SDL_RenderDebugTextFormat;
|
||||
# extra symbols go here (don't modify this line)
|
||||
local: *;
|
||||
};
|
||||
|
@@ -1232,5 +1232,4 @@
|
||||
#define SDL_SetGPUAllowedFramesInFlight SDL_SetGPUAllowedFramesInFlight_REAL
|
||||
#define SDL_RenderTextureAffine SDL_RenderTextureAffine_REAL
|
||||
#define SDL_WaitAndAcquireGPUSwapchainTexture SDL_WaitAndAcquireGPUSwapchainTexture_REAL
|
||||
#define SDL_RenderDebugTextF SDL_RenderDebugTextF_REAL
|
||||
#define SDL_RenderDebugTextV SDL_RenderDebugTextV_REAL
|
||||
#define SDL_RenderDebugTextFormat SDL_RenderDebugTextFormat_REAL
|
||||
|
@@ -1239,6 +1239,5 @@ SDL_DYNAPI_PROC(bool,SDL_SetGPUAllowedFramesInFlight,(SDL_GPUDevice *a,Uint32 b)
|
||||
SDL_DYNAPI_PROC(bool,SDL_RenderTextureAffine,(SDL_Renderer *a,SDL_Texture *b,const SDL_FRect *c,const SDL_FPoint *d,const SDL_FPoint *e,const SDL_FPoint *f),(a,b,c,d,e,f),return)
|
||||
SDL_DYNAPI_PROC(bool,SDL_WaitAndAcquireGPUSwapchainTexture,(SDL_GPUCommandBuffer *a,SDL_Window *b,SDL_GPUTexture **c,Uint32 *d,Uint32 *e),(a,b,c,d,e),return)
|
||||
#ifndef SDL_DYNAPI_PROC_NO_VARARGS
|
||||
SDL_DYNAPI_PROC(bool,SDL_RenderDebugTextF,(SDL_Renderer *a,float b,float c,SDL_PRINTF_FORMAT_STRING const char *d,...),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(bool,SDL_RenderDebugTextFormat,(SDL_Renderer *a,float b,float c,SDL_PRINTF_FORMAT_STRING const char *d,...),(a,b,c,d),return)
|
||||
#endif
|
||||
SDL_DYNAPI_PROC(bool,SDL_RenderDebugTextV,(SDL_Renderer *a,float b,float c,SDL_PRINTF_FORMAT_STRING const char *d,va_list e),(a,b,c,d,e),return)
|
||||
|
Reference in New Issue
Block a user