|
18 | 18 | #define SDL_MAIN_USE_CALLBACKS |
19 | 19 | #include <SDL3/SDL_main.h> |
20 | 20 |
|
21 | | -/* =============================================================== |
22 | | - * |
23 | | - * CONFIG |
24 | | - * |
25 | | - * ===============================================================*/ |
26 | | - |
27 | | -/* optional: sdl3_renderer does not need any of these defines |
28 | | - * (but some examples might need them, so be careful) */ |
29 | | -#define NK_INCLUDE_STANDARD_VARARGS |
30 | | -#define NK_INCLUDE_STANDARD_IO |
31 | | - |
32 | | -/* note that sdl3_renderer comes with nk_sdl_style_set_debug_font() |
33 | | - * so you may wish to use that instead of font baking */ |
34 | | -#define NK_INCLUDE_FONT_BAKING |
35 | | -#define NK_INCLUDE_DEFAULT_FONT |
36 | | - |
37 | | -/* note that sdl3_renderer comes with nk_sdl_allocator() |
38 | | - * and you probably want to use that allocator instead of the default ones */ |
39 | | -/*#define NK_INCLUDE_DEFAULT_ALLOCATOR*/ |
40 | | - |
41 | | -/* mandatory: sdl3_renderer depends on those defines */ |
42 | | -#define NK_INCLUDE_COMMAND_USERDATA |
43 | | -#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT |
44 | | - |
45 | | - |
46 | | -/* We can re-use the types provided by SDL which are extremely portable, |
47 | | - * so there is no need for Nuklear to detect those on its own */ |
48 | | -/*#define NK_INCLUDE_FIXED_TYPES*/ |
49 | | -#ifndef NK_INCLUDE_FIXED_TYPES |
50 | | - #define NK_INT8 Sint8 |
51 | | - #define NK_UINT8 Uint8 |
52 | | - #define NK_INT16 Sint16 |
53 | | - #define NK_UINT16 Uint16 |
54 | | - #define NK_INT32 Sint32 |
55 | | - #define NK_UINT32 Uint32 |
56 | | - /* SDL guarantees 'uintptr_t' typedef */ |
57 | | - #define NK_SIZE_TYPE uintptr_t |
58 | | - #define NK_POINTER_TYPE uintptr_t |
59 | | -#endif |
60 | | - |
61 | | -/* We can reuse the `bool` symbol because SDL3 guarantees its existence */ |
62 | | -/*#define NK_INCLUDE_STANDARD_BOOL*/ |
63 | | -#ifndef NK_INCLUDE_STANDARD_BOOL |
64 | | - #define NK_BOOL bool |
65 | | -#endif |
66 | | - |
67 | | -/* We can re-use various portable libc functions provided by SDL */ |
68 | | -#define NK_ASSERT(condition) SDL_assert(condition) |
69 | | -#define NK_STATIC_ASSERT(exp) SDL_COMPILE_TIME_ASSERT(, exp) |
70 | | -#define NK_MEMSET(dst, c, len) SDL_memset(dst, c, len) |
71 | | -#define NK_MEMCPY(dst, src, len) SDL_memcpy(dst, src, len) |
72 | | -#define NK_VSNPRINTF(s, n, f, a) SDL_vsnprintf(s, n, f, a) |
73 | | -#define NK_STRTOD(str, endptr) SDL_strtod(str, endptr) |
74 | | - |
75 | | -/* SDL3 does not provide "dtoa" (only integer versions) |
76 | | - * but we can emulate it with SDL_snprintf */ |
77 | | -static char* nk_sdl_dtoa(char *str, double d); |
78 | | -#define NK_DTOA(str, d) nk_sdl_dtoa(str, d) |
79 | | - |
80 | | -/* SDL can also provide us with math functions, but beware that Nuklear's own |
81 | | - * implementation can be slightly faster at the cost of some precision */ |
82 | | -#define NK_INV_SQRT(f) (1.0f / SDL_sqrtf(f)) |
83 | | -#define NK_SIN(f) SDL_sinf(f) |
84 | | -#define NK_COS(f) SDL_cosf(f) |
85 | | - |
86 | | -/* HACK: Nuklear pulls two stb libraries in order to use font baking |
87 | | - * those libraries pull in some libc headers internally, creating a linkage dependency, |
88 | | - * so you’ll most likely want to use SDL symbols instead */ |
89 | | -#define STBTT_ifloor(x) ((int)SDL_floor(x)) |
90 | | -#define STBTT_iceil(x) ((int)SDL_ceil(x)) |
91 | | -#define STBTT_sqrt(x) SDL_sqrt(x) |
92 | | -#define STBTT_pow(x,y) SDL_pow(x,y) |
93 | | -#define STBTT_fmod(x,y) SDL_fmod(x,y) |
94 | | -#define STBTT_cos(x) SDL_cosf(x) |
95 | | -#define STBTT_acos(x) SDL_acos(x) |
96 | | -#define STBTT_fabs(x) SDL_fabs(x) |
97 | | -#define STBTT_assert(x) SDL_assert(x) |
98 | | -#define STBTT_strlen(x) SDL_strlen(x) |
99 | | -#define STBTT_memcpy SDL_memcpy |
100 | | -#define STBTT_memset SDL_memset |
101 | | -#define stbtt_uint8 Uint8 |
102 | | -#define stbtt_int8 Sint8 |
103 | | -#define stbtt_uint16 Uint16 |
104 | | -#define stbtt_int16 Sint16 |
105 | | -#define stbtt_uint32 Uint32 |
106 | | -#define stbtt_int32 Sint32 |
107 | | -#define STBRP_SORT SDL_qsort |
108 | | -#define STBRP_ASSERT SDL_assert |
109 | | -/* There is no need to define STBTT_malloc/STBTT_free macros |
110 | | - * Nuklear will define those to user-provided nk_allocator */ |
111 | | - |
112 | | - |
| 21 | +#include "./nuklear_sdl3_renderer_config.h" |
113 | 22 | #define NK_IMPLEMENTATION |
114 | 23 | #include "../../nuklear.h" |
115 | 24 | #define NK_SDL3_RENDERER_IMPLEMENTATION |
@@ -421,12 +330,3 @@ SDL_AppQuit(void* appstate, SDL_AppResult result) |
421 | 330 | } |
422 | 331 | } |
423 | 332 |
|
424 | | -static char* |
425 | | -nk_sdl_dtoa(char *str, double d) |
426 | | -{ |
427 | | - NK_ASSERT(str); |
428 | | - if (!str) return NULL; |
429 | | - (void)SDL_snprintf(str, 99999, "%.17g", d); |
430 | | - return str; |
431 | | -} |
432 | | - |
0 commit comments