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