Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port dcimgui to importC - CI fix #39

Merged
merged 2 commits into from
Dec 6, 2024
Merged

Port dcimgui to importC - CI fix #39

merged 2 commits into from
Dec 6, 2024

Conversation

kassane
Copy link
Owner

@kassane kassane commented Dec 5, 2024

info: https://dlang.org/spec/importc.html
pragma attribute(push, nogc, nothrow): https://dlang.org/changelog/pending.html#dmd.importc-pragma-stc

Note

D compiler scans the C file(s) and apply semantic analyzer regardless of file type.

Reference

@kassane kassane requested a review from floooh December 5, 2024 18:10
@kassane kassane added the fix fixing bug label Dec 5, 2024
@kassane
Copy link
Owner Author

kassane commented Dec 5, 2024

With importC, ldc2/ldmd2 call $CC flags and on Windows cl flags.

@kassane
Copy link
Owner Author

kassane commented Dec 5, 2024

Ignore warning:

In file included from /home/runner/work/sokol-d/sokol-d/src/cimgui/dcimgui.c:6:
In file included from /home/runner/.cache/zig/p/1220190c1c465474d437a8f7955c8b759e6e4ef32e9a61e9f0b5dbe74ebcd84622b3/src/cimgui.h:93:
In file included from /home/runner/.cache/zig/p/12201d024e47d97dea4d1d6024a9cf1b35ca8be8e4fa1a0ecf6ee9080e479467183a/upstream/emscripten/cache/sysroot/include/assert.h:1:
/home/runner/.cache/zig/p/12201d024e47d97dea4d1d6024a9cf1b35ca8be8e4fa1a0ecf6ee9080e479467183a/upstream/emscripten/cache/sysroot/include/features.h:27:9: warning: '__restrict' macro redefined [-Wmacro-redefined]
   27 | #define __restrict restrict
      |         ^
/opt/hostedtoolcache/ldc2/82878ef3/x64/ldc2-82878ef3-linux-x86_64/bin/../import/importc.h:28:9: note: previous definition is here
   28 | #define __restrict
      |         ^
1 warning generated.

@kassane
Copy link
Owner Author

kassane commented Dec 5, 2024

commit e7e81f9 - msvc target: need cc to emscripten target. However, 1a7ed3b use zigcc-wrapper (a.k.a ldc2 -gcc=zcc.exe ...)

@kassane
Copy link
Owner Author

kassane commented Dec 5, 2024

Next step:

fix dub - cimgui not found
dub build :imgui
    Starting Performing "debug" build using /home/kassane/.local/ldc2-82878ef3-linux-x86_64/bin/ldc2 for x86_64.
    Building sokol-d:imgui 0.1.6: building configuration [application]
   Pre-build Running commands
src/cimgui/dcimgui.c:6:10: fatal error: cimgui.h: No such file or directory
    6 | #include <cimgui.h>
      |          ^~~~~~~~~~
compilation terminated.
src/cimgui/cimgui.d(4,15): Error: /usr/bin/cc failed with status: 1

How to export zig-pkg to env:ZIG_GLOBAL_CACHE_DIR?

@floooh
Copy link
Collaborator

floooh commented Dec 5, 2024

I'm also currently in the process of fixing the differences between the original cimgui API and the dear_bindings API.

One important difference I noticed is that the new C bindings header must be compiled in C11 mode (there are some duplicate symbol definitions in the header which are valid in C11, but not C99 - I don't know if this intended or just an oversight in the bindings generator).

Also: I decided to call the resulting static link library just imgui (not cimgui), because the library can actually be used both for writing Dear ImGui code in C++ and C (since a complete Dear ImGui is included in the library anyway, and the dcimgui repository has a complete copy of the Dear ImGui sources and headers).

@kassane
Copy link
Owner Author

kassane commented Dec 5, 2024

I decided to call the resulting static link library just imgui (not cimgui),

Nice! I've renamed the package to imgui, but the module remains cimgui. Since ImportC (default C11) can read C code and C++ bindings only manually.

You can currently choose between c99, c11, UAX31 (C23's) and all (the least restrictive set) for both D and ImportC.
[...]
The default table for D is currently set to all, while ImportC is set to c11. Previously both D and ImportC used the c99 tables. - https://dlang.org/changelog/2.109.0.html#dmd.identifier-tables

@kassane kassane marked this pull request as ready for review December 5, 2024 19:28
@@ -216,6 +218,8 @@ subPackage {
libs "sokol"
lflags "-Lzig-out/lib" platform="posix"
lflags "/LIBPATH:zig-out/lib" platform="windows"
dflags "-P-I$HOME/.cache/zig/p/1220190c1c465474d437a8f7955c8b759e6e4ef32e9a61e9f0b5dbe74ebcd84622b3/src" platform="posix"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


- name: (Zig) Build Shaders
run: zig build shaders
- name: (Zig) Running Test
if: runner.os != 'Windows'
run: zig build test -DzigCC
- name: (Zig) Build Native
run: zig build -DzigCC --summary all
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, zigcc-wrapper as lld emit warnings on Linux:

ld.lld: warning: /home/kassane/sokol-d/.zig-cache/o/83dda58209fccbe4164f94e931ca58d7/libsokol.a: archive member '/lib64/libasound.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/kassane/sokol-d/.zig-cache/o/83dda58209fccbe4164f94e931ca58d7/libsokol.a: archive member '/lib64/libGL.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/kassane/sokol-d/.zig-cache/o/83dda58209fccbe4164f94e931ca58d7/libsokol.a: archive member '/lib64/libX11.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/kassane/sokol-d/.zig-cache/o/83dda58209fccbe4164f94e931ca58d7/libsokol.a: archive member '/lib64/libXi.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/kassane/sokol-d/.zig-cache/o/83dda58209fccbe4164f94e931ca58d7/libsokol.a: archive member '/lib64/libXcursor.so' is neither ET_REL nor LLVM bitcode

but, works!!

@kassane
Copy link
Owner Author

kassane commented Dec 5, 2024

I haven't discovered who is giving the warning in wasm32 target (ldc2-master [llvm19], zig-master [llvm19], emcc [llvm20] - set generic-cpu):
'-half-precision' is not a recognized feature for this target (ignoring feature)


update: emcc emit warnings with LTO enabled and Zig emit target-features on LLVM-IR.

@kassane kassane changed the title Port dcimgui to importC Port dcimgui to importC - CI fix Dec 6, 2024
@kassane kassane self-assigned this Dec 6, 2024
@kassane
Copy link
Owner Author

kassane commented Dec 6, 2024

The change to dcimgui (via importC) has already been merged. It is worth emphasizing that any changes made in the headers are currently incorporated when updating the zon (imgui pkg). b6591f0

// Use importC to import the C header files.
#ifndef DCIMGUI_H
#define DCIMGUI_H
#pragma attribute(push, nogc, nothrow) // dmd-2.110.x feature
#include <cimgui.h>
#pragma attribute(pop)
#endif // DCIMGUI_H

// get dcimgui headers to module - @system (unsafe) functions by default
public import cimgui.dcimgui;

@kassane
Copy link
Owner Author

kassane commented Dec 6, 2024

// Use importC to import the C header files.
#ifndef DCIMGUI_H
#define DCIMGUI_H
#pragma attribute(push, nogc, nothrow) // dmd-2.110.x feature
#include <cimgui.h>
#pragma attribute(pop)
#endif // DCIMGUI_H

importC cannot support header files, only *.c and *.i.

References

https://issues.dlang.org/show_bug.cgi?id=23479
https://issues.dlang.org/show_bug.cgi?id=23547

@kassane kassane merged commit 66140da into main Dec 6, 2024
3 checks passed
@kassane kassane deleted the fix-cimgui branch December 6, 2024 14:30
@floooh
Copy link
Collaborator

floooh commented Dec 6, 2024

Hey @kassane, I updated dcimgui again to add a docking version (so that there's now an all-in-one repo both for C++ and C, and the regular vs docking-branch-version of Dear ImGui.

I hope this doesn't break your current work, but if yes the changes should be minimal (I force-pushed the 1.95.1 tag though).

(also see the updated readme: https://github.com/floooh/dcimgui)

@kassane
Copy link
Owner Author

kassane commented Dec 6, 2024

I updated dcimgui again to add a docking version [...]

Nice! 704b9dd

I hope this doesn't break your current work, but if yes the changes should be minimal (I force-pushed the 1.95.1 tag though).

No problem.
image

@floooh
Copy link
Collaborator

floooh commented Dec 7, 2024

FYI I'll try a few more things in dcimgui in the next few days and may force-push the tag 1.91.5 again (hope that isn't too disruptive):

  • see if I can add another C binding without any prefix, so that in Zig it's possible to write ig.SetNextWindowPos() instead of ig.igSetNextWindowPos()
  • probably add yet another C binding with the default prefix ImGui_ for people who prefer the new dear_bindings default naming scheme
  • ...and I'm thinking about moving the build.zig from here: https://github.com/floooh/sokol-zig-imgui-sample/tree/main/deps/cimgui directly into the dcimgui repo - but that's the one thing I'm not yet sure about :)

@kassane
Copy link
Owner Author

kassane commented Dec 7, 2024

see if I can add another C binding without any prefix, so that in Zig it's possible to write ig.SetNextWindowPos() instead of ig.igSetNextWindowPos()

Avoiding naming redundancies will make your code more readable. When declaring modules in Zig and D, it is possible to easily make import naming compatible, which is already the case in the examples.

Using importC and updating the dcimgui package hash any changes in cimgui.h will be easily detected and fixed in the examples later.

The negative point of importC, in my opinion, is the fact that the D compiler analyzes C files using D rules.
I've had a little problem involving inline asm [in C code to importC] with string concatenation (requires GC in D).

And also the editor can't autocomplete code from importC.

I'm thinking about moving the build.zig from here: https://github.com/floooh/sokol-zig-imgui-sample/tree/main/deps/cimgui  directly into the dcimgui repo - but that's the one thing I'm not yet sure about :)

Moving build.zig to dcimgui would allow standardizing the build config (zig-cache global) for any project involving Zig build-system.

Unlike sokol-d which just imports dcimgui and configures build in zig-cache local.

The good thing is that it becomes more convenient for zig users to build without configuring it individually per project.

@floooh
Copy link
Collaborator

floooh commented Dec 7, 2024

Ok, the dcimgui repo can now be used directly as Zig module (see the build.zig and build.zig.zon):

https://github.com/floooh/dcimgui

...and the changes in the sokol-zig-imgui-sample:

floooh/sokol-zig-imgui-sample@073a6ce

...I had to keep the ig.ig... convention for now, because sokol_imgui.h needs to be updated too for the 'prefix-less' naming convention (otherwise it works though via the zimgui.h and zimgui.cpp source files in dcimgui - those are the C bindings without ig prefix).

@kassane
Copy link
Owner Author

kassane commented Dec 7, 2024

zimgui is wip?

my local test, works on D:

diff changes
diff --git a/build.zig b/build.zig
index 53c1a0c..157f597 100644
--- a/build.zig
+++ b/build.zig
@@ -923,7 +923,7 @@ fn buildImgui(b: *Build, options: libImGuiOptions) !*CompileStep {
     libimgui.addCSourceFiles(.{
         .root = cimgui,
         .files = &.{
-            "cimgui.cpp",
+            "zimgui.cpp",
         },
         .flags = &.{
             "-Wall",
diff --git a/src/cimgui/dcimgui.c b/src/cimgui/dcimgui.c
index c9674fb..b537fd3 100644
--- a/src/cimgui/dcimgui.c
+++ b/src/cimgui/dcimgui.c
@@ -3,6 +3,6 @@
 #ifndef DCIMGUI_H
 #define DCIMGUI_H
 #pragma attribute(push, nogc, nothrow) // dmd-2.110.x feature
-#include <cimgui.h>
+#include <zimgui.h>
 #pragma attribute(pop)
 #endif // DCIMGUI_H
diff --git a/src/examples/imgui.d b/src/examples/imgui.d
index 7f3e91a..dbc6372 100644
--- a/src/examples/imgui.d
+++ b/src/examples/imgui.d
@@ -11,7 +11,7 @@ import sgapp = sokol.glue;
 import sapp = sokol.app;
 import imgui = sokol.imgui;
 import log = sokol.log;
-import cimgui.cimgui;
+import ig = cimgui.cimgui;
 
 extern (C):
 @safe:
@@ -52,19 +52,19 @@ void frame() @trusted
     imgui.newFrame(imgui_desc);
 
     /*=== UI CODE STARTS HERE ===*/
-    const ImVec2 window_pos = {10, 10};
-    const ImVec2 window_size = {400, 100};
-    igSetNextWindowPos(window_pos, ImGuiCond_.ImGuiCond_Once);
-    igSetNextWindowSize(window_size, ImGuiCond_.ImGuiCond_Once);
-    igBegin("Hello Dear ImGui!".ptr, null, ImGuiWindowFlags_.ImGuiWindowFlags_None);
+    const ig.ImVec2 window_pos = {10, 10};
+    const ig.ImVec2 window_size = {400, 100};
+    ig.SetNextWindowPos(window_pos, ig.ImGuiCond_.ImGuiCond_Once);
+    ig.SetNextWindowSize(window_size, ig.ImGuiCond_.ImGuiCond_Once);
+    ig.Begin("Hello Dear ImGui!".ptr, null, ig.ImGuiWindowFlags_.ImGuiWindowFlags_None);
     const(char)* label = "Background";
     float[3] rgb = [
         state.pass_action.colors[0].clear_value.r,
         state.pass_action.colors[0].clear_value.g,
         state.pass_action.colors[0].clear_value.b
     ];
-    igColorEdit3(label, &rgb[0], ImGuiColorEditFlags_.ImGuiColorEditFlags_None);
-    igEnd();
+    ig.ColorEdit3(label, &rgb[0], ig.ImGuiColorEditFlags_.ImGuiColorEditFlags_None);
+    ig.End();
     /*=== UI CODE ENDS HERE ===*/
 
     sg.Pass pass = {action: state.pass_action, swapchain: sgapp.swapchain};
diff --git a/src/sokol/c/sokol_imgui.c b/src/sokol/c/sokol_imgui.c
index 346be8a..ae256d0 100644
--- a/src/sokol/c/sokol_imgui.c
+++ b/src/sokol/c/sokol_imgui.c
@@ -1,7 +1,7 @@
 #if defined(IMPL)
 #define SOKOL_IMGUI_IMPL
 #define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
-#include "cimgui.h"
+#include "zimgui.h"
 #endif
 #include "sokol_defines.h"
 #include "sokol_app.h"
diff --git a/src/sokol/c/sokol_imgui.h b/src/sokol/c/sokol_imgui.h
index 1a7c650..fa2e50d 100644
--- a/src/sokol/c/sokol_imgui.h
+++ b/src/sokol/c/sokol_imgui.h
@@ -2650,9 +2650,9 @@ SOKOL_API_IMPL void simgui_setup(const simgui_desc_t* desc) {
             io->Fonts->AddFontDefault();
         }
     #else
-        igCreateContext(NULL);
-        igStyleColorsDark(igGetStyle());
-        ImGuiIO* io = igGetIO();
+        CreateContext(NULL);
+        StyleColorsDark(GetStyle());
+        ImGuiIO* io = GetIO();
         if (!_simgui.desc.no_default_font) {
             ImFontAtlas_AddFontDefault(io->Fonts, NULL);
         }
@@ -2667,7 +2667,7 @@ SOKOL_API_IMPL void simgui_setup(const simgui_desc_t* desc) {
         #if defined(__cplusplus)
             ImGuiPlatformIO* pio = &ImGui::GetPlatformIO();
         #else
-            ImGuiPlatformIO* pio = igGetPlatformIO();
+            ImGuiPlatformIO* pio = GetPlatformIO();
         #endif
         pio->Platform_SetClipboardTextFn = _simgui_set_clipboard;
         pio->Platform_GetClipboardTextFn = _simgui_get_clipboard;
@@ -2850,7 +2850,7 @@ SOKOL_API_IMPL void simgui_create_fonts_texture(const simgui_font_tex_desc_t* de
     #if defined(__cplusplus)
         ImGuiIO* io = &ImGui::GetIO();
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
     #endif
 
     // a default font sampler
@@ -2904,7 +2904,7 @@ SOKOL_API_IMPL void simgui_shutdown(void) {
     #if defined(__cplusplus)
         ImGui::DestroyContext();
     #else
-        igDestroyContext(0);
+        DestroyContext(0);
     #endif
     // NOTE: it's valid to call the destroy funcs with SG_INVALID_ID
     sg_destroy_pipeline(_simgui.pip_unfilterable);
@@ -2980,7 +2980,7 @@ SOKOL_API_IMPL void simgui_new_frame(const simgui_frame_desc_t* desc) {
     #if defined(__cplusplus)
         ImGuiIO* io = &ImGui::GetIO();
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
     #endif
     if (!io->Fonts->TexReady) {
         simgui_destroy_fonts_texture();
@@ -3002,7 +3002,7 @@ SOKOL_API_IMPL void simgui_new_frame(const simgui_frame_desc_t* desc) {
             #if defined(__cplusplus)
                 ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
             #else
-                ImGuiMouseCursor imgui_cursor = igGetMouseCursor();
+                ImGuiMouseCursor imgui_cursor = GetMouseCursor();
             #endif
             sapp_mouse_cursor cursor = sapp_get_mouse_cursor();
             switch (imgui_cursor) {
@@ -3023,7 +3023,7 @@ SOKOL_API_IMPL void simgui_new_frame(const simgui_frame_desc_t* desc) {
     #if defined(__cplusplus)
         ImGui::NewFrame();
     #else
-        igNewFrame();
+        NewFrame();
     #endif
 }
 
@@ -3054,9 +3054,9 @@ SOKOL_API_IMPL void simgui_render(void) {
         ImDrawData* draw_data = ImGui::GetDrawData();
         ImGuiIO* io = &ImGui::GetIO();
     #else
-        igRender();
-        ImDrawData* draw_data = igGetDrawData();
-        ImGuiIO* io = igGetIO();
+        Render();
+        ImDrawData* draw_data = GetDrawData();
+        ImGuiIO* io = GetIO();
     #endif
     if (0 == draw_data) {
         return;
@@ -3207,7 +3207,7 @@ SOKOL_API_IMPL void simgui_add_focus_event(bool focus) {
         ImGuiIO* io = &ImGui::GetIO();
         io->AddFocusEvent(focus);
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
         ImGuiIO_AddFocusEvent(io, focus);
     #endif
 }
@@ -3221,7 +3221,7 @@ SOKOL_API_IMPL void simgui_add_mouse_pos_event(float x, float y) {
         #endif
         io->AddMousePosEvent(x, y);
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
         #if (IMGUI_VERSION_NUM >= 18950)
         ImGuiIO_AddMouseSourceEvent(io, ImGuiMouseSource_Mouse);
         #endif
@@ -3238,7 +3238,7 @@ SOKOL_API_IMPL void simgui_add_touch_pos_event(float x, float y) {
         #endif
         io->AddMousePosEvent(x, y);
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
         #if (IMGUI_VERSION_NUM >= 18950)
         ImGuiIO_AddMouseSourceEvent(io, ImGuiMouseSource_TouchScreen);
         #endif
@@ -3255,7 +3255,7 @@ SOKOL_API_IMPL void simgui_add_mouse_button_event(int mouse_button, bool down) {
         #endif
         io->AddMouseButtonEvent(mouse_button, down);
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
         #if (IMGUI_VERSION_NUM >= 18950)
         ImGuiIO_AddMouseSourceEvent(io, ImGuiMouseSource_Mouse);
         #endif
@@ -3272,7 +3272,7 @@ SOKOL_API_IMPL void simgui_add_touch_button_event(int mouse_button, bool down) {
         #endif
         io->AddMouseButtonEvent(mouse_button, down);
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
         #if (IMGUI_VERSION_NUM >= 18950)
         ImGuiIO_AddMouseSourceEvent(io, ImGuiMouseSource_TouchScreen);
         #endif
@@ -3289,7 +3289,7 @@ SOKOL_API_IMPL void simgui_add_mouse_wheel_event(float wheel_x, float wheel_y) {
         #endif
         io->AddMouseWheelEvent(wheel_x, wheel_y);
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
         #if (IMGUI_VERSION_NUM >= 18950)
         ImGuiIO_AddMouseSourceEvent(io, ImGuiMouseSource_Mouse);
         #endif
@@ -3303,7 +3303,7 @@ SOKOL_API_IMPL void simgui_add_key_event(int imgui_key, bool down) {
         ImGuiIO* io = &ImGui::GetIO();
         io->AddKeyEvent((ImGuiKey)imgui_key, down);
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
         ImGuiIO_AddKeyEvent(io, (ImGuiKey)imgui_key, down);
     #endif
 }
@@ -3314,7 +3314,7 @@ SOKOL_API_IMPL void simgui_add_input_character(uint32_t c) {
         ImGuiIO* io = &ImGui::GetIO();
         io->AddInputCharacter(c);
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
         ImGuiIO_AddInputCharacter(io, c);
     #endif
 }
@@ -3325,7 +3325,7 @@ SOKOL_API_IMPL void simgui_add_input_characters_utf8(const char* c) {
         ImGuiIO* io = &ImGui::GetIO();
         io->AddInputCharactersUTF8(c);
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
         ImGuiIO_AddInputCharactersUTF8(io, c);
     #endif
 }
@@ -3490,7 +3490,7 @@ SOKOL_API_IMPL bool simgui_handle_event(const sapp_event* ev) {
     #if defined(__cplusplus)
         ImGuiIO* io = &ImGui::GetIO();
     #else
-        ImGuiIO* io = igGetIO();
+        ImGuiIO* io = GetIO();
     #endif
     switch (ev->type) {
         case SAPP_EVENTTYPE_FOCUSED:

get same result:

image

@floooh
Copy link
Collaborator

floooh commented Dec 8, 2024

Well yeah, with changes in sokol_imgui.h it works. I need to come up with a way to pass the prefix into sokol_imgui.h so that it can work with different C API naming conventions.

@floooh
Copy link
Collaborator

floooh commented Dec 8, 2024

FYI: floooh/sokol#1166

This allows to override the C prefix in sokol_imgui.

...next I'll add more options to sokol-zig's sokol library compilation to allow overriding both this prefix and the cimgui.h header path.

Associated commit in sokol-zig: floooh/sokol-zig@3132888

...switching the dcimgui/build.zig over to zimgui.cpp/zimgui.h: floooh/dcimgui@85ddb04

...and finally how it's all coming together:

floooh/sokol-zig-imgui-sample@256fb67

@floooh
Copy link
Collaborator

floooh commented Dec 8, 2024

Ah sh*t, the prefix-less cimgui functions collide with Win32 operating system functions :/

https://github.com/floooh/sokol-zig-imgui-sample/actions/runs/12223678665/job/34095519722

Argh... I'll go back to the 'ig' prefix for now :/

...I think the only way to get rid of the prefix is to use the dear_bindings meta-data to create a Zig module (similar to the sokol-zig bindings generation) instead of relying on the TranslateC feature. That way we could also switch to camelCase (e.g. ig.setWindowPos() instead of ig.SetWindowPos().

...that's for a later time though...

@kassane
Copy link
Owner Author

kassane commented Dec 10, 2024

switching the dcimgui/build.zig over to zimgui.cpp/zimgui.h: floooh/dcimgui@85ddb04

my suggestion for dcimgui/build.zig switching between docking or default 518249b

@floooh
Copy link
Collaborator

floooh commented Dec 10, 2024

Hmm, in the CMakeLists.txt file I create two separate libraries (imgui and imgui-docking):

https://github.com/floooh/dcimgui/blob/71851ebf5393e229d31851cafebea2211f7b6d59/CMakeLists.txt#L25-L41

...maybe it makes sense to expose two similar modules from the dcimgui build.zig? I haven't thought about using the docking version in the language bindings yet tbh.

@kassane
Copy link
Owner Author

kassane commented Dec 10, 2024

Hmm, in the CMakeLists.txt file I create two separate libraries (imgui and imgui-docking):

https://github.com/floooh/dcimgui/blob/71851ebf5393e229d31851cafebea2211f7b6d59/CMakeLists.txt#L25-L41

...maybe it makes sense to expose two similar modules from the dcimgui build.zig? I haven't thought about using the docking version in the language bindings yet tbh.

Maybe! It is common in cmake.
Now it's trivial for a zig user to build quickly and use only the necessary dependencies.

Based on 518249b

  • Both imgui will have the same files, with different implementations.
    No need to rename library and also no need add extra files...

You can ask the zig community about this if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix fixing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants