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