1 /++ 2 + Machine generated D bindings for Sokol library. 3 + 4 + Generated on: 2025-06-01 10:38:03 5 + 6 + Source header: sokol_debugtext.h 7 + Module: sokol.debugtext 8 + 9 + Do not edit manually; regenerate using gen_d.py. 10 +/ 11 module sokol.debugtext; 12 import sg = sokol.gfx; 13 14 enum LogItem { 15 Ok, 16 Malloc_failed, 17 Add_commit_listener_failed, 18 Command_buffer_full, 19 Context_pool_exhausted, 20 Cannot_destroy_default_context, 21 } 22 /++ 23 + sdtx_logger_t 24 + 25 + Used in sdtx_desc_t to provide a custom logging and error reporting 26 + callback to sokol-debugtext. 27 +/ 28 extern(C) struct Logger { 29 extern(C) void function(const(char)*, uint, uint, const(char)*, uint, const(char)*, void*) func = null; 30 void* user_data = null; 31 } 32 /++ 33 + a rendering context handle 34 +/ 35 extern(C) struct Context { 36 uint id = 0; 37 } 38 /++ 39 + sdtx_range is a pointer-size-pair struct used to pass memory 40 + blobs into sokol-debugtext. When initialized from a value type 41 + (array or struct), use the SDTX_RANGE() macro to build 42 + an sdtx_range struct. 43 +/ 44 extern(C) struct Range { 45 const(void)* ptr = null; 46 size_t size = 0; 47 } 48 extern(C) struct FontDesc { 49 Range data = {}; 50 ubyte first_char = 0; 51 ubyte last_char = 0; 52 } 53 /++ 54 + sdtx_context_desc_t 55 + 56 + Describes the initialization parameters of a rendering context. Creating 57 + additional rendering contexts is useful if you want to render in 58 + different sokol-gfx rendering passes, or when rendering several layers 59 + of text. 60 +/ 61 extern(C) struct ContextDesc { 62 int max_commands = 0; 63 int char_buf_size = 0; 64 float canvas_width = 0.0f; 65 float canvas_height = 0.0f; 66 int tab_width = 0; 67 sg.PixelFormat color_format = sg.PixelFormat.Default; 68 sg.PixelFormat depth_format = sg.PixelFormat.Default; 69 int sample_count = 0; 70 } 71 /++ 72 + sdtx_allocator_t 73 + 74 + Used in sdtx_desc_t to provide custom memory-alloc and -free functions 75 + to sokol_debugtext.h. If memory management should be overridden, both the 76 + alloc_fn and free_fn function must be provided (e.g. it's not valid to 77 + override one function but not the other). 78 +/ 79 extern(C) struct Allocator { 80 extern(C) void* function(size_t, void*) alloc_fn = null; 81 extern(C) void function(void*, void*) free_fn = null; 82 void* user_data = null; 83 } 84 /++ 85 + sdtx_desc_t 86 + 87 + Describes the sokol-debugtext API initialization parameters. Passed 88 + to the sdtx_setup() function. 89 + 90 + NOTE: to populate the fonts item array with builtin fonts, use any 91 + of the following functions: 92 + 93 + sdtx_font_kc853() 94 + sdtx_font_kc854() 95 + sdtx_font_z1013() 96 + sdtx_font_cpc() 97 + sdtx_font_c64() 98 + sdtx_font_oric() 99 +/ 100 extern(C) struct Desc { 101 int context_pool_size = 0; 102 int printf_buf_size = 0; 103 FontDesc[8] fonts = []; 104 ContextDesc context = {}; 105 Allocator allocator = {}; 106 Logger logger = {}; 107 } 108 /++ 109 + initialization/shutdown 110 +/ 111 extern(C) void sdtx_setup(const Desc* desc) @system @nogc nothrow pure; 112 void setup(scope ref Desc desc) @trusted @nogc nothrow pure { 113 sdtx_setup(&desc); 114 } 115 extern(C) void sdtx_shutdown() @system @nogc nothrow pure; 116 void shutdown() @trusted @nogc nothrow pure { 117 sdtx_shutdown(); 118 } 119 /++ 120 + builtin font data (use to populate sdtx_desc.font[]) 121 +/ 122 extern(C) FontDesc sdtx_font_kc853() @system @nogc nothrow pure; 123 FontDesc fontKc853() @trusted @nogc nothrow pure { 124 return sdtx_font_kc853(); 125 } 126 extern(C) FontDesc sdtx_font_kc854() @system @nogc nothrow pure; 127 FontDesc fontKc854() @trusted @nogc nothrow pure { 128 return sdtx_font_kc854(); 129 } 130 extern(C) FontDesc sdtx_font_z1013() @system @nogc nothrow pure; 131 FontDesc fontZ1013() @trusted @nogc nothrow pure { 132 return sdtx_font_z1013(); 133 } 134 extern(C) FontDesc sdtx_font_cpc() @system @nogc nothrow pure; 135 FontDesc fontCpc() @trusted @nogc nothrow pure { 136 return sdtx_font_cpc(); 137 } 138 extern(C) FontDesc sdtx_font_c64() @system @nogc nothrow pure; 139 FontDesc fontC64() @trusted @nogc nothrow pure { 140 return sdtx_font_c64(); 141 } 142 extern(C) FontDesc sdtx_font_oric() @system @nogc nothrow pure; 143 FontDesc fontOric() @trusted @nogc nothrow pure { 144 return sdtx_font_oric(); 145 } 146 /++ 147 + context functions 148 +/ 149 extern(C) Context sdtx_make_context(const ContextDesc* desc) @system @nogc nothrow pure; 150 Context makeContext(scope ref ContextDesc desc) @trusted @nogc nothrow pure { 151 return sdtx_make_context(&desc); 152 } 153 extern(C) void sdtx_destroy_context(Context ctx) @system @nogc nothrow pure; 154 void destroyContext(Context ctx) @trusted @nogc nothrow pure { 155 sdtx_destroy_context(ctx); 156 } 157 extern(C) void sdtx_set_context(Context ctx) @system @nogc nothrow pure; 158 void setContext(Context ctx) @trusted @nogc nothrow pure { 159 sdtx_set_context(ctx); 160 } 161 extern(C) Context sdtx_get_context() @system @nogc nothrow pure; 162 Context getContext() @trusted @nogc nothrow pure { 163 return sdtx_get_context(); 164 } 165 extern(C) Context sdtx_default_context() @system @nogc nothrow pure; 166 Context defaultContext() @trusted @nogc nothrow pure { 167 return sdtx_default_context(); 168 } 169 /++ 170 + drawing functions (call inside sokol-gfx render pass) 171 +/ 172 extern(C) void sdtx_draw() @system @nogc nothrow pure; 173 void draw() @trusted @nogc nothrow pure { 174 sdtx_draw(); 175 } 176 extern(C) void sdtx_context_draw(Context ctx) @system @nogc nothrow pure; 177 void contextDraw(Context ctx) @trusted @nogc nothrow pure { 178 sdtx_context_draw(ctx); 179 } 180 extern(C) void sdtx_draw_layer(int layer_id) @system @nogc nothrow pure; 181 void drawLayer(int layer_id) @trusted @nogc nothrow pure { 182 sdtx_draw_layer(layer_id); 183 } 184 extern(C) void sdtx_context_draw_layer(Context ctx, int layer_id) @system @nogc nothrow pure; 185 void contextDrawLayer(Context ctx, int layer_id) @trusted @nogc nothrow pure { 186 sdtx_context_draw_layer(ctx, layer_id); 187 } 188 /++ 189 + switch render layer 190 +/ 191 extern(C) void sdtx_layer(int layer_id) @system @nogc nothrow pure; 192 void layer(int layer_id) @trusted @nogc nothrow pure { 193 sdtx_layer(layer_id); 194 } 195 /++ 196 + switch to a different font 197 +/ 198 extern(C) void sdtx_font(uint font_index) @system @nogc nothrow pure; 199 void font(uint font_index) @trusted @nogc nothrow pure { 200 sdtx_font(font_index); 201 } 202 /++ 203 + set a new virtual canvas size in screen pixels 204 +/ 205 extern(C) void sdtx_canvas(float w, float h) @system @nogc nothrow pure; 206 void canvas(float w, float h) @trusted @nogc nothrow pure { 207 sdtx_canvas(w, h); 208 } 209 /++ 210 + set a new origin in character grid coordinates 211 +/ 212 extern(C) void sdtx_origin(float x, float y) @system @nogc nothrow pure; 213 void origin(float x, float y) @trusted @nogc nothrow pure { 214 sdtx_origin(x, y); 215 } 216 /++ 217 + cursor movement functions (relative to origin in character grid coordinates) 218 +/ 219 extern(C) void sdtx_home() @system @nogc nothrow pure; 220 void home() @trusted @nogc nothrow pure { 221 sdtx_home(); 222 } 223 extern(C) void sdtx_pos(float x, float y) @system @nogc nothrow pure; 224 void pos(float x, float y) @trusted @nogc nothrow pure { 225 sdtx_pos(x, y); 226 } 227 extern(C) void sdtx_pos_x(float x) @system @nogc nothrow pure; 228 void posX(float x) @trusted @nogc nothrow pure { 229 sdtx_pos_x(x); 230 } 231 extern(C) void sdtx_pos_y(float y) @system @nogc nothrow pure; 232 void posY(float y) @trusted @nogc nothrow pure { 233 sdtx_pos_y(y); 234 } 235 extern(C) void sdtx_move(float dx, float dy) @system @nogc nothrow pure; 236 void move(float dx, float dy) @trusted @nogc nothrow pure { 237 sdtx_move(dx, dy); 238 } 239 extern(C) void sdtx_move_x(float dx) @system @nogc nothrow pure; 240 void moveX(float dx) @trusted @nogc nothrow pure { 241 sdtx_move_x(dx); 242 } 243 extern(C) void sdtx_move_y(float dy) @system @nogc nothrow pure; 244 void moveY(float dy) @trusted @nogc nothrow pure { 245 sdtx_move_y(dy); 246 } 247 extern(C) void sdtx_crlf() @system @nogc nothrow pure; 248 void crlf() @trusted @nogc nothrow pure { 249 sdtx_crlf(); 250 } 251 /++ 252 + set the current text color 253 +/ 254 extern(C) void sdtx_color3b(ubyte r, ubyte g, ubyte b) @system @nogc nothrow pure; 255 void color3b(ubyte r, ubyte g, ubyte b) @trusted @nogc nothrow pure { 256 sdtx_color3b(r, g, b); 257 } 258 extern(C) void sdtx_color3f(float r, float g, float b) @system @nogc nothrow pure; 259 void color3f(float r, float g, float b) @trusted @nogc nothrow pure { 260 sdtx_color3f(r, g, b); 261 } 262 extern(C) void sdtx_color4b(ubyte r, ubyte g, ubyte b, ubyte a) @system @nogc nothrow pure; 263 void color4b(ubyte r, ubyte g, ubyte b, ubyte a) @trusted @nogc nothrow pure { 264 sdtx_color4b(r, g, b, a); 265 } 266 extern(C) void sdtx_color4f(float r, float g, float b, float a) @system @nogc nothrow pure; 267 void color4f(float r, float g, float b, float a) @trusted @nogc nothrow pure { 268 sdtx_color4f(r, g, b, a); 269 } 270 extern(C) void sdtx_color1i(uint rgba) @system @nogc nothrow pure; 271 void color1i(uint rgba) @trusted @nogc nothrow pure { 272 sdtx_color1i(rgba); 273 } 274 /++ 275 + text rendering 276 +/ 277 extern(C) void sdtx_putc(char c) @system @nogc nothrow pure; 278 void putc(char c) @trusted @nogc nothrow pure { 279 sdtx_putc(c); 280 } 281 extern(C) void sdtx_puts(const(char)* str) @system @nogc nothrow pure; 282 void puts(const(char)* str) @trusted @nogc nothrow pure { 283 sdtx_puts(str); 284 } 285 extern(C) void sdtx_putr(const(char)* str, int len) @system @nogc nothrow pure; 286 void putr(const(char)* str, int len) @trusted @nogc nothrow pure { 287 sdtx_putr(str, len); 288 }