From 7457cae7337d58f09f95294904321a5d5aa14230 Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Tue, 15 Jul 2025 18:53:00 +0200 Subject: sokol_debugtext.h: expose the internal string-format buffer to language bindings (used by sokol-zig) --- util/sokol_debugtext.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'util/sokol_debugtext.h') diff --git a/util/sokol_debugtext.h b/util/sokol_debugtext.h index 826cf675..61759257 100644 --- a/util/sokol_debugtext.h +++ b/util/sokol_debugtext.h @@ -753,6 +753,9 @@ SOKOL_DEBUGTEXT_API_DECL void sdtx_putr(const char* str, int len); // 'put ra SOKOL_DEBUGTEXT_API_DECL int sdtx_printf(const char* fmt, ...) SOKOL_DEBUGTEXT_PRINTF_ATTR; SOKOL_DEBUGTEXT_API_DECL int sdtx_vprintf(const char* fmt, va_list args); +/* language bindings helper: get the internal printf format buffer */ +SOKOL_DEBUGTEXT_API_DECL sdtx_range sdtx_get_cleared_fmt_buffer(void); + #ifdef __cplusplus } /* extern "C" */ /* C++ const-ref wrappers */ @@ -4955,6 +4958,16 @@ SOKOL_DEBUGTEXT_API_DECL int sdtx_printf(const char* fmt, ...) { return res; } +SOKOL_DEBUGTEXT_API_DECL sdtx_range sdtx_get_cleared_fmt_buffer(void) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + SOKOL_ASSERT(_sdtx.fmt_buf && (_sdtx.fmt_buf_size >= 2)); + memset(_sdtx.fmt_buf, 0, _sdtx.fmt_buf_size); + sdtx_range res; _sdtx_clear(&res, sizeof(res)); + res.ptr = _sdtx.fmt_buf; + res.size = _sdtx.fmt_buf_size - 1; + return res; +} + SOKOL_API_IMPL void sdtx_draw(void) { SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); _sdtx_context_t* ctx = _sdtx.cur_ctx; -- cgit v1.2.3