diff options
| author | Andre Weissflog <floooh@gmail.com> | 2019-05-16 15:32:01 +0200 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2019-05-16 15:32:01 +0200 |
| commit | f380099970a30efd0e65195c160e877d90184623 (patch) | |
| tree | 2530b173c8c7a16800556bb804141881f87175ae /util | |
| parent | 77a28e7cab077ee1db8340ad8429a9afd52d8139 (diff) | |
some cleanup in sokol_cimgui.h
Diffstat (limited to 'util')
| -rw-r--r-- | util/sokol_cimgui.h | 671 |
1 files changed, 335 insertions, 336 deletions
diff --git a/util/sokol_cimgui.h b/util/sokol_cimgui.h index 88b38e41..2cd46b4d 100644 --- a/util/sokol_cimgui.h +++ b/util/sokol_cimgui.h @@ -1,6 +1,6 @@ #pragma once /* - sokol_cimgui.h -- drop-in Dear ImGui renderer/event-handler for sokol_gfx.h + sokol_cimgui.h -- Dear ImGui renderer using cimgui C bindings Do this: #define SOKOL_CIMGUI_IMPL @@ -20,7 +20,7 @@ Optionally provide the following configuration defines before including the implementation: - SOKOL_IMGUI_NO_SOKOL_APP - don't depend on sokol_app.h (see below for details) + SOKOL_CIMGUI_NO_SOKOL_APP - don't depend on sokol_app.h (see below for details) Optionally provide the following macros before including the implementatuon to override defaults: @@ -33,27 +33,22 @@ the declaration and implementation): sokol_gfx.h - sokol_app.h (except SOKOL_IMGUI_NO_SOKOL_APP) + sokol_app.h (except SOKOL_CIMGUI_NO_SOKOL_APP) Additionally, include the following headers before including the implementation: cimgui.h - Note that the sokol_imgui.h *implementation* must be compiled as C++ - (since Dear ImGui has a C++ API). - - FIXME: replace embedded Metal shader sources with precompiled bytecode blobs(?) - FEATURE OVERVIEW: ================= - sokol_imgui.h implements the initialization, rendering and event-handling + sokol_cimgui.h implements the initialization, rendering and event-handling code for Dear ImGui (https://github.com/ocornut/imgui) on top of sokol_gfx.h and (optionally) sokol_app.h. The sokol_app.h dependency is optional and used for input event handling. If you only use sokol_gfx.h but not sokol_app.h in your application, - define SOKOL_IMGUI_NO_SOKOL_APP before including the implementation + define SOKOL_CIMGUI_NO_SOKOL_APP before including the implementation of sokol_imgui.h, this will remove any dependency to sokol_app.h, but you must feed input events into Dear ImGui yourself. @@ -97,7 +92,7 @@ const char* ini_filename Use this path as igGetIO()->IniFilename. By default - this is 0, so that Dear ImGui will not do any + this is 0, so that Dear ImGui will not do any filesystem calls. bool no_default_font @@ -113,7 +108,7 @@ passed to igGetIO()->DisplaySize. 'delta_time' is the frame duration passed to igGetIO()->DeltaTime. - + For example, if you're using sokol_app.h and render to the default framebuffer: @@ -173,7 +168,7 @@ #if !defined(SOKOL_GFX_INCLUDED) #error "Please include sokol_gfx.h before sokol_imgui.h" #endif -#if !defined(SOKOL_IMGUI_NO_SOKOL_APP) && !defined(SOKOL_APP_INCLUDED) +#if !defined(SOKOL_CIMGUI_NO_SOKOL_APP) && !defined(SOKOL_APP_INCLUDED) #error "Please include sokol_app.h before sokol_imgui.h" #endif @@ -194,7 +189,7 @@ typedef struct scimgui_desc_t { SOKOL_API_DECL void scimgui_setup(const scimgui_desc_t* desc); SOKOL_API_DECL void scimgui_new_frame(int width, int height, double delta_time); SOKOL_API_DECL void scimgui_render(void); -#if !defined(SOKOL_IMGUI_NO_SOKOL_APP) +#if !defined(SOKOL_CIMGUI_NO_SOKOL_APP) SOKOL_API_DECL bool scimgui_handle_event(const sapp_event* ev); #endif SOKOL_API_DECL void scimgui_shutdown(void); @@ -206,9 +201,6 @@ SOKOL_API_DECL void scimgui_shutdown(void); #if !defined(CIMGUI_DEFINE_ENUMS_AND_STRUCTS) #error "Please include cimgui.h before the sokol_cimgui.h implementation" #endif -#if defined(__cplusplus) -#error "The sokol_cimgui.h implementation must be compiled as C" -#endif #include <stddef.h> /* offsetof */ #include <string.h> /* memset */ @@ -235,6 +227,7 @@ SOKOL_API_DECL void scimgui_shutdown(void); /* helper macros */ #define _scimgui_def(val, def) (((val) == 0) ? (def) : (val)) +#define _scimgui_clear(val) memset(&val, 0, sizeof(val)) typedef struct { ImVec2 disp_size; @@ -247,7 +240,7 @@ typedef struct { sg_image img; sg_shader shd; sg_pipeline pip; - #if !defined(SOKOL_IMGUI_NO_SOKOL_APP) + #if !defined(SOKOL_CIMGUI_NO_SOKOL_APP) bool btn_down[SAPP_MAX_MOUSEBUTTONS]; bool btn_up[SAPP_MAX_MOUSEBUTTONS]; #endif @@ -362,7 +355,7 @@ static const char* _scimgui_fs_src = outp.color = inp.color; return outp; } - + Fragment shader source: Texture2D<float4> tex: register(t0); @@ -372,291 +365,291 @@ static const char* _scimgui_fs_src = } */ static const uint8_t _scimgui_vs_bin[] = { - 68, 88, 66, 67, 204, 137, - 115, 177, 245, 67, 161, 195, - 58, 224, 90, 35, 76, 123, - 88, 146, 1, 0, 0, 0, - 244, 3, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 64, 1, 0, 0, 176, 1, - 0, 0, 36, 2, 0, 0, - 88, 3, 0, 0, 82, 68, - 69, 70, 4, 1, 0, 0, - 1, 0, 0, 0, 100, 0, - 0, 0, 1, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 254, 255, 0, 145, 0, 0, - 220, 0, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 112, 97, 114, 97, - 109, 115, 0, 171, 92, 0, - 0, 0, 1, 0, 0, 0, - 124, 0, 0, 0, 16, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 164, 0, - 0, 0, 0, 0, 0, 0, - 8, 0, 0, 0, 2, 0, - 0, 0, 184, 0, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 100, 105, 115, 112, - 95, 115, 105, 122, 101, 0, - 102, 108, 111, 97, 116, 50, - 0, 171, 171, 171, 1, 0, - 3, 0, 1, 0, 2, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 174, 0, 0, 0, 77, 105, - 99, 114, 111, 115, 111, 102, - 116, 32, 40, 82, 41, 32, - 72, 76, 83, 76, 32, 83, - 104, 97, 100, 101, 114, 32, - 67, 111, 109, 112, 105, 108, - 101, 114, 32, 49, 48, 46, - 49, 0, 73, 83, 71, 78, - 104, 0, 0, 0, 3, 0, - 0, 0, 8, 0, 0, 0, - 80, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 0, 0, - 89, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 3, 3, 0, 0, - 98, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 2, 0, - 0, 0, 15, 15, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 84, 69, 88, - 67, 79, 79, 82, 68, 0, - 67, 79, 76, 79, 82, 0, - 79, 83, 71, 78, 108, 0, - 0, 0, 3, 0, 0, 0, - 8, 0, 0, 0, 80, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 3, 12, 0, 0, 89, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 15, 0, 0, 0, 95, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 2, 0, 0, 0, - 15, 0, 0, 0, 84, 69, - 88, 67, 79, 79, 82, 68, - 0, 67, 79, 76, 79, 82, - 0, 83, 86, 95, 80, 111, - 115, 105, 116, 105, 111, 110, - 0, 171, 83, 72, 69, 88, - 44, 1, 0, 0, 80, 0, - 1, 0, 75, 0, 0, 0, - 106, 8, 0, 1, 89, 0, - 0, 4, 70, 142, 32, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 95, 0, 0, 3, - 50, 16, 16, 0, 0, 0, - 0, 0, 95, 0, 0, 3, - 50, 16, 16, 0, 1, 0, - 0, 0, 95, 0, 0, 3, - 242, 16, 16, 0, 2, 0, - 0, 0, 101, 0, 0, 3, - 50, 32, 16, 0, 0, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 1, 0, - 0, 0, 103, 0, 0, 4, - 242, 32, 16, 0, 2, 0, - 0, 0, 1, 0, 0, 0, - 104, 0, 0, 2, 1, 0, - 0, 0, 54, 0, 0, 5, - 50, 32, 16, 0, 0, 0, - 0, 0, 70, 16, 16, 0, - 1, 0, 0, 0, 54, 0, - 0, 5, 242, 32, 16, 0, - 1, 0, 0, 0, 70, 30, - 16, 0, 2, 0, 0, 0, - 14, 0, 0, 8, 50, 0, - 16, 0, 0, 0, 0, 0, - 70, 16, 16, 0, 0, 0, - 0, 0, 70, 128, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 10, - 50, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 191, - 0, 0, 0, 191, 0, 0, - 0, 0, 0, 0, 0, 0, - 56, 0, 0, 10, 50, 32, - 16, 0, 2, 0, 0, 0, - 70, 0, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 64, 0, 0, - 0, 192, 0, 0, 0, 0, - 0, 0, 0, 0, 54, 0, - 0, 8, 194, 32, 16, 0, - 2, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 63, 0, 0, 128, 63, - 62, 0, 0, 1, 83, 84, - 65, 84, 148, 0, 0, 0, - 7, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, + 68, 88, 66, 67, 204, 137, + 115, 177, 245, 67, 161, 195, + 58, 224, 90, 35, 76, 123, + 88, 146, 1, 0, 0, 0, + 244, 3, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 64, 1, 0, 0, 176, 1, + 0, 0, 36, 2, 0, 0, + 88, 3, 0, 0, 82, 68, + 69, 70, 4, 1, 0, 0, + 1, 0, 0, 0, 100, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 145, 0, 0, + 220, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 112, 97, 114, 97, + 109, 115, 0, 171, 92, 0, + 0, 0, 1, 0, 0, 0, + 124, 0, 0, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 164, 0, + 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 2, 0, + 0, 0, 184, 0, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 100, 105, 115, 112, + 95, 115, 105, 122, 101, 0, + 102, 108, 111, 97, 116, 50, + 0, 171, 171, 171, 1, 0, + 3, 0, 1, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 174, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 49, 48, 46, + 49, 0, 73, 83, 71, 78, + 104, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 3, 0, 0, + 89, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 98, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 67, 79, 76, 79, 82, 0, + 79, 83, 71, 78, 108, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 12, 0, 0, 89, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 95, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 0, 0, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 67, 79, 76, 79, 82, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171, 83, 72, 69, 88, + 44, 1, 0, 0, 80, 0, + 1, 0, 75, 0, 0, 0, + 106, 8, 0, 1, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 54, 0, 0, 5, + 50, 32, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 2, 0, 0, 0, + 14, 0, 0, 8, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 0, 0, + 0, 0, 70, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 10, + 50, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 191, + 0, 0, 0, 191, 0, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 10, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 64, 0, 0, + 0, 192, 0, 0, 0, 0, + 0, 0, 0, 0, 54, 0, + 0, 8, 194, 32, 16, 0, + 2, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 63, 0, 0, 128, 63, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 7, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const uint8_t _scimgui_fs_bin[] = { - 68, 88, 66, 67, 116, 27, - 191, 2, 170, 79, 42, 154, - 39, 13, 69, 105, 240, 12, - 136, 97, 1, 0, 0, 0, - 176, 2, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 232, 0, 0, 0, 56, 1, - 0, 0, 108, 1, 0, 0, - 20, 2, 0, 0, 82, 68, - 69, 70, 172, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 145, 0, 0, - 132, 0, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 124, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 128, 0, 0, 0, - 2, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 1, 0, 0, 0, - 13, 0, 0, 0, 115, 109, - 112, 0, 116, 101, 120, 0, - 77, 105, 99, 114, 111, 115, - 111, 102, 116, 32, 40, 82, - 41, 32, 72, 76, 83, 76, - 32, 83, 104, 97, 100, 101, - 114, 32, 67, 111, 109, 112, - 105, 108, 101, 114, 32, 49, - 48, 46, 49, 0, 73, 83, - 71, 78, 72, 0, 0, 0, - 2, 0, 0, 0, 8, 0, - 0, 0, 56, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 3, 3, - 0, 0, 65, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 15, 15, - 0, 0, 84, 69, 88, 67, - 79, 79, 82, 68, 0, 67, - 79, 76, 79, 82, 0, 171, - 79, 83, 71, 78, 44, 0, - 0, 0, 1, 0, 0, 0, - 8, 0, 0, 0, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 83, 86, - 95, 84, 97, 114, 103, 101, - 116, 0, 171, 171, 83, 72, - 69, 88, 160, 0, 0, 0, - 80, 0, 0, 0, 40, 0, - 0, 0, 106, 8, 0, 1, - 90, 0, 0, 3, 0, 96, - 16, 0, 0, 0, 0, 0, - 88, 24, 0, 4, 0, 112, - 16, 0, 0, 0, 0, 0, - 85, 85, 0, 0, 98, 16, - 0, 3, 50, 16, 16, 0, - 0, 0, 0, 0, 98, 16, - 0, 3, 242, 16, 16, 0, - 1, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 0, 0, 0, 0, 104, 0, - 0, 2, 1, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 16, 16, 0, - 0, 0, 0, 0, 70, 126, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 242, 32, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 70, 30, - 16, 0, 1, 0, 0, 0, - 62, 0, 0, 1, 83, 84, - 65, 84, 148, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, + 68, 88, 66, 67, 116, 27, + 191, 2, 170, 79, 42, 154, + 39, 13, 69, 105, 240, 12, + 136, 97, 1, 0, 0, 0, + 176, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 232, 0, 0, 0, 56, 1, + 0, 0, 108, 1, 0, 0, + 20, 2, 0, 0, 82, 68, + 69, 70, 172, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 145, 0, 0, + 132, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 124, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 128, 0, 0, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 1, 0, 0, 0, + 13, 0, 0, 0, 115, 109, + 112, 0, 116, 101, 120, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 49, + 48, 46, 49, 0, 73, 83, + 71, 78, 72, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 3, 3, + 0, 0, 65, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 15, + 0, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 67, + 79, 76, 79, 82, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171, 83, 72, + 69, 88, 160, 0, 0, 0, + 80, 0, 0, 0, 40, 0, + 0, 0, 106, 8, 0, 1, + 90, 0, 0, 3, 0, 96, + 16, 0, 0, 0, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 0, 0, 0, 0, + 85, 85, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 0, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 1, 0, 0, 0, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 0, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #else @@ -665,7 +658,7 @@ static const uint8_t _scimgui_fs_bin[] = { SOKOL_API_IMPL void scimgui_setup(const scimgui_desc_t* desc) { SOKOL_ASSERT(desc); - memset(&_scimgui, 0, sizeof(_scimgui)); + _scimgui_clear(_scimgui); _scimgui.desc = *desc; _scimgui.desc.max_vertices = _scimgui_def(_scimgui.desc.max_vertices, 65536); _scimgui.desc.dpi_scale = _scimgui_def(_scimgui.desc.dpi_scale, 1.0f); @@ -674,16 +667,16 @@ SOKOL_API_IMPL void scimgui_setup(const scimgui_desc_t* desc) { */ /* initialize Dear ImGui */ - igCreateContext(NULL); - igStyleColorsDark(igGetStyle()); - - ImGuiIO* io = igGetIO(); + igCreateContext(NULL); + igStyleColorsDark(igGetStyle()); + + ImGuiIO* io = igGetIO(); if (!_scimgui.desc.no_default_font) { - ImFontAtlas_AddFontDefault(io->Fonts, NULL); + ImFontAtlas_AddFontDefault(io->Fonts, NULL); } - + io->IniFilename = _scimgui.desc.ini_filename; - #if !defined(SOKOL_IMGUI_NO_SOKOL_APP) + #if !defined(SOKOL_CIMGUI_NO_SOKOL_APP) io->KeyMap[ImGuiKey_Tab] = SAPP_KEYCODE_TAB; io->KeyMap[ImGuiKey_LeftArrow] = SAPP_KEYCODE_LEFT; io->KeyMap[ImGuiKey_RightArrow] = SAPP_KEYCODE_RIGHT; @@ -709,13 +702,15 @@ SOKOL_API_IMPL void scimgui_setup(const scimgui_desc_t* desc) { /* create sokol-gfx resources */ sg_push_debug_group("sokol-imgui"); - sg_buffer_desc vb_desc = { }; + sg_buffer_desc vb_desc; + _scimgui_clear(vb_desc); vb_desc.usage = SG_USAGE_STREAM; vb_desc.size = _scimgui.desc.max_vertices * sizeof(ImDrawVert); vb_desc.label = "sokol-imgui-vertices"; _scimgui.vbuf = sg_make_buffer(&vb_desc); - sg_buffer_desc ib_desc = { }; + sg_buffer_desc ib_desc; + _scimgui_clear(ib_desc); ib_desc.type = SG_BUFFERTYPE_INDEXBUFFER; ib_desc.usage = SG_USAGE_STREAM; ib_desc.size = _scimgui.desc.max_vertices * 3 * sizeof(uint16_t); @@ -725,10 +720,11 @@ SOKOL_API_IMPL void scimgui_setup(const scimgui_desc_t* desc) { /* default font texture */ if (!_scimgui.desc.no_default_font) { unsigned char* font_pixels; - int font_width, font_height, bytes_per_pixel; - ImFontAtlas_GetTexDataAsRGBA32(io->Fonts, &font_pixels, &font_width, &font_height, &bytes_per_pixel); - - sg_image_desc img_desc = { }; + int font_width, font_height, bytes_per_pixel; + ImFontAtlas_GetTexDataAsRGBA32(io->Fonts, &font_pixels, &font_width, &font_height, &bytes_per_pixel); + + sg_image_desc img_desc; + _scimgui_clear(img_desc); img_desc.width = font_width; img_desc.height = font_height; img_desc.pixel_format = SG_PIXELFORMAT_RGBA8; @@ -744,8 +740,9 @@ SOKOL_API_IMPL void scimgui_setup(const scimgui_desc_t* desc) { } /* shader object for using the embedded shader source (or bytecode) */ - sg_shader_desc shd_desc = { }; - sg_shader_uniform_block_desc *ub = &shd_desc.vs.uniform_blocks[0]; + sg_shader_desc shd_desc; + _scimgui_clear(shd_desc); + sg_shader_uniform_block_desc *ub = &shd_desc.vs.uniform_blocks[0]; ub->size = sizeof(_scimgui_vs_params_t); ub->uniforms[0].name = "disp_size"; ub->uniforms[0].type = SG_UNIFORMTYPE_FLOAT2; @@ -770,7 +767,8 @@ SOKOL_API_IMPL void scimgui_setup(const scimgui_desc_t* desc) { _scimgui.shd = sg_make_shader(&shd_desc); /* pipeline object for imgui rendering */ - sg_pipeline_desc pip_desc = { }; + sg_pipeline_desc pip_desc; + _scimgui_clear(pip_desc); pip_desc.layout.buffers[0].stride = sizeof(ImDrawVert); { sg_vertex_attr_desc* attr = &pip_desc.layout.attrs[0]; @@ -812,11 +810,11 @@ SOKOL_API_IMPL void scimgui_shutdown(void) { } SOKOL_API_IMPL void scimgui_new_frame(int width, int height, double delta_time) { - ImGuiIO* io = igGetIO(); + ImGuiIO* io = igGetIO(); io->DisplaySize.x = (float) width; io->DisplaySize.y = (float) height; io->DeltaTime = (float) delta_time; - #if !defined(SOKOL_IMGUI_NO_SOKOL_APP) + #if !defined(SOKOL_CIMGUI_NO_SOKOL_APP) for (int i = 0; i < SAPP_MAX_MOUSEBUTTONS; i++) { if (_scimgui.btn_down[i]) { _scimgui.btn_down[i] = false; @@ -834,12 +832,12 @@ SOKOL_API_IMPL void scimgui_new_frame(int width, int height, double delta_time) sapp_show_keyboard(false); } #endif - igNewFrame(); + igNewFrame(); } SOKOL_API_IMPL void scimgui_render(void) { - igRender(); - ImDrawData* draw_data = igGetDrawData(); + igRender(); + ImDrawData* draw_data = igGetDrawData(); if (draw_data == NULL) { return; } @@ -852,13 +850,14 @@ SOKOL_API_IMPL void scimgui_render(void) { sg_push_debug_group("sokol-imgui"); sg_apply_pipeline(_scimgui.pip); _scimgui_vs_params_t vs_params; - vs_params.disp_size.x = igGetIO()->DisplaySize.x / dpi_scale; - vs_params.disp_size.y = igGetIO()->DisplaySize.y / dpi_scale; + vs_params.disp_size.x = igGetIO()->DisplaySize.x / dpi_scale; + vs_params.disp_size.y = igGetIO()->DisplaySize.y / dpi_scale; sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &vs_params, sizeof(vs_params)); - sg_bindings bind = { }; + sg_bindings bind; + _scimgui_clear(bind); bind.vertex_buffers[0] = _scimgui.vbuf; bind.index_buffer = _scimgui.ibuf; - ImTextureID tex_id = igGetIO()->Fonts->TexID; + ImTextureID tex_id = igGetIO()->Fonts->TexID; bind.fs_images[0].id = (uint32_t)(uintptr_t)tex_id; for (int cl_index = 0; cl_index < draw_data->CmdListsCount; cl_index++) { const ImDrawList* cl = draw_data->CmdLists[cl_index]; @@ -866,9 +865,9 @@ SOKOL_API_IMPL void scimgui_render(void) { /* append vertices and indices to buffers, record start offsets in draw state */ const int vtx_size = cl->VtxBuffer.Size * sizeof(ImDrawVert); const int idx_size = cl->IdxBuffer.Size * sizeof(ImDrawIdx); - - ImVector_ImDrawVert vertex_buffer = cl->VtxBuffer; - ImVector_ImDrawIdx draw_idx = cl->IdxBuffer; + + ImVector_ImDrawVert vertex_buffer = cl->VtxBuffer; + ImVector_ImDrawIdx draw_idx = cl->IdxBuffer; const int vb_offset = sg_append_buffer(bind.vertex_buffers[0], ImVector_ImDrawVert_front(&vertex_buffer), vtx_size); const int ib_offset = sg_append_buffer(bind.index_buffer, ImVector_ImDrawIdx_front(&draw_idx), idx_size); /* don't render anything if the buffer is in overflow state (this is also @@ -885,9 +884,9 @@ SOKOL_API_IMPL void scimgui_render(void) { sg_apply_bindings(&bind); int base_element = 0; - for (int i = 0; i < cl->CmdBuffer.Size; i++) - { - ImDrawCmd pcmd = cl->CmdBuffer.Data[i]; + for (int i = 0; i < cl->CmdBuffer.Size; i++) + { + ImDrawCmd pcmd = cl->CmdBuffer.Data[i]; if (pcmd.UserCallback) { pcmd.UserCallback(cl, &pcmd); } @@ -910,10 +909,10 @@ SOKOL_API_IMPL void scimgui_render(void) { sg_pop_debug_group(); } -#if !defined(SOKOL_IMGUI_NO_SOKOL_APP) +#if !defined(SOKOL_CIMGUI_NO_SOKOL_APP) SOKOL_API_IMPL bool scimgui_handle_event(const sapp_event* ev) { const float dpi_scale = _scimgui.desc.dpi_scale; - ImGuiIO* io = igGetIO(); + ImGuiIO* io = igGetIO(); io->KeyAlt = (ev->modifiers & SAPP_MODIFIER_ALT) != 0; io->KeyCtrl = (ev->modifiers & SAPP_MODIFIER_CTRL) != 0; io->KeyShift = (ev->modifiers & SAPP_MODIFIER_SHIFT) != 0; @@ -973,7 +972,7 @@ SOKOL_API_IMPL bool scimgui_handle_event(const sapp_event* ev) { io->KeysDown[ev->key_code] = false; break; case SAPP_EVENTTYPE_CHAR: - ImGuiIO_AddInputCharacter(io, (ImWchar)ev->char_code); + ImGuiIO_AddInputCharacter(io, (ImWchar)ev->char_code); break; default: break; |