digitalmars.D.learn - Looking for a simple GUI library that works with Vulkan on SDL2
- Danny Arends (17/17) Feb 19 Hey all,
- ryuukk_ (17/34) Feb 19 Nuklear works with D (ImportC) out of the box, you don't need any
- Danny Arends (20/35) Feb 20 Thanks for the heads up, unfortunately including the
- Richard (Rikki) Andrew Cattermole (3/46) Feb 20 That's not -betterC, that's ImportC, different feature.
- Danny Arends (3/8) Feb 20 Right, I always get those 2 confused... I mean importC indeed :)
- ryuukk_ (6/6) Feb 19 Forgot to mention:
- bauss (17/23) Feb 19 There's also DVN which is a visual novel engine, BUT it contains
- IchorDev (35/43) Feb 19 Actually, I have been working on an update to BindBC-ImGui for a
- Danny Arends (18/63) Feb 20 Thanks,
- IchorDev (6/23) Jul 04 Sorry for the late response. I missed this post.
- Luna (8/25) Jul 08 i2d-imgui was updated recently. Do note that to use this package
Hey all, I am looking to integrate a GUI library like IMgui / Nuklear into my app that uses Vulkan within SDL2 for rendering so that it can run on Windows, Linux, and Android (https://github.com/DannyArends/CalderaD). I've tried several different bindings to IMgui, however, none seem to work and seem abandoned to me (the most recent updated one 'bindbc-imgui' was updated 3 years ago). For Nuklear, the most up2date package (bindbc-nuklear) seems to build, but doesn't provide a Vulkan back-end example so I'm kind of stuck with how I'm supposed to integrate it (I might make the effort to translate the C-code example provided in the https://github.com/Immediate-Mode-UI/Nuklear repository to D) But this got me wondering, what is the state of the art GUI library in D, when I am using modern OpenGL or Vulkan ? Does anyone have any tips or tricks on how to achieve a basic GUI ? (without writing yet another GUI library binding from scratch)
Feb 19
On Wednesday, 19 February 2025 at 15:21:19 UTC, Danny Arends wrote:Hey all, I am looking to integrate a GUI library like IMgui / Nuklear into my app that uses Vulkan within SDL2 for rendering so that it can run on Windows, Linux, and Android (https://github.com/DannyArends/CalderaD). I've tried several different bindings to IMgui, however, none seem to work and seem abandoned to me (the most recent updated one 'bindbc-imgui' was updated 3 years ago). For Nuklear, the most up2date package (bindbc-nuklear) seems to build, but doesn't provide a Vulkan back-end example so I'm kind of stuck with how I'm supposed to integrate it (I might make the effort to translate the C-code example provided in the https://github.com/Immediate-Mode-UI/Nuklear repository to D) But this got me wondering, what is the state of the art GUI library in D, when I am using modern OpenGL or Vulkan ? Does anyone have any tips or tricks on how to achieve a basic GUI ? (without writing yet another GUI library binding from scratch)Nuklear works with D (ImportC) out of the box, you don't need any binding, that's what i'm using in my game nk.c ``` // add other configs you need #define NK_INCLUDE_VERTEX_BUFFER_OUTPUT #define NK_IMPLEMENTATION #include "nuklear.h" ``` app.d ```D import nk; ``` Then the examples are 1:1, C/D is the same Stick to simplicity, and get rewarded for it
Feb 19
On Wednesday, 19 February 2025 at 15:53:02 UTC, ryuukk_ wrote:Nuklear works with D (ImportC) out of the box, you don't need any binding, that's what i'm using in my game nk.c ``` // add other configs you need #define NK_INCLUDE_VERTEX_BUFFER_OUTPUT #define NK_IMPLEMENTATION #include "nuklear.h" ``` app.d ```D import nk; ``` Then the examples are 1:1, C/D is the same Stick to simplicity, and get rewarded for itThanks for the heads up, unfortunately including the nuklear_sdl_vulkan.h doesn't seem to work out of the box with ImportC and causes all kinds of compilation errors: ``` /usr/lib/gcc/x86_64-linux-gnu/9/include/bmi2intrin.h(86,21): Error: unsigned __int128 not supported /usr/lib/gcc/x86_64-linux-gnu/9/include/sgxintrin.h(141,3): Error: found `else` without a corresponding `if` statement /usr/lib/gcc/x86_64-linux-gnu/9/include/sgxintrin.h(174,3): Error: no type for declarator before `return` /usr/lib/gcc/x86_64-linux-gnu/9/include/sgxintrin.h(175,1): Error: no type for ../Nuklear/demo/sdl_vulkan/nuklear_sdl_vulkan.h(442,46): Error: expression expected, not `)` ../Nuklear/demo/sdl_vulkan/nuklear_sdl_vulkan.h(442,47): Error: found `malloc` when expecting `)` ``` Seems I will have to wait for betterC to become better at C, Is there a formal way of report these errors ?
Feb 20
On 20/02/2025 10:58 PM, Danny Arends wrote:On Wednesday, 19 February 2025 at 15:53:02 UTC, ryuukk_ wrote:That's not -betterC, that's ImportC, different feature. This one has a similar report: https://github.com/dlang/dmd/issues/20470Nuklear works with D (ImportC) out of the box, you don't need any binding, that's what i'm using in my game nk.c ``` // add other configs you need #define NK_INCLUDE_VERTEX_BUFFER_OUTPUT #define NK_IMPLEMENTATION #include "nuklear.h" ``` app.d ```D import nk; ``` Then the examples are 1:1, C/D is the same Stick to simplicity, and get rewarded for itThanks for the heads up, unfortunately including the nuklear_sdl_vulkan.h doesn't seem to work out of the box with ImportC and causes all kinds of compilation errors: ``` /usr/lib/gcc/x86_64-linux-gnu/9/include/bmi2intrin.h(86,21): Error: unsigned __int128 not supported /usr/lib/gcc/x86_64-linux-gnu/9/include/sgxintrin.h(141,3): Error: found `else` without a corresponding `if` statement /usr/lib/gcc/x86_64-linux-gnu/9/include/sgxintrin.h(174,3): Error: no type for declarator before `return` /usr/lib/gcc/x86_64-linux-gnu/9/include/sgxintrin.h(175,1): Error: no type for ../Nuklear/demo/sdl_vulkan/nuklear_sdl_vulkan.h(442,46): Error: expression expected, not `)` ../Nuklear/demo/sdl_vulkan/nuklear_sdl_vulkan.h(442,47): Error: found `malloc` when expecting `)` ``` Seems I will have to wait for betterC to become better at C, Is there a formal way of report these errors ?
Feb 20
On Thursday, 20 February 2025 at 10:02:31 UTC, Richard (Rikki) Andrew Cattermole wrote:On 20/02/2025 10:58 PM, Danny Arends wrote:Right, I always get those 2 confused... I mean importC indeed :)[...]That's not -betterC, that's ImportC, different feature. This one has a similar report: https://github.com/dlang/dmd/issues/20470
Feb 20
Forgot to mention: nanogui from drug007: https://github.com/drug007/nanogui Fluid from arta: https://forum.dlang.org/thread/wwdqjlrlbzyvodmktrcx forum.dlang.org minigui from adam: https://arsd-official.dpldocs.info/arsd.minigui.html
Feb 19
On Wednesday, 19 February 2025 at 15:59:38 UTC, ryuukk_ wrote:Forgot to mention: nanogui from drug007: https://github.com/drug007/nanogui Fluid from arta: https://forum.dlang.org/thread/wwdqjlrlbzyvodmktrcx forum.dlang.org minigui from adam: https://arsd-official.dpldocs.info/arsd.minigui.htmlThere's also DVN which is a visual novel engine, BUT it contains a GUI library and the whole of DVN is a source library package, so it should be easy to just use the GUI part of the language. https://github.com/ProjectDVN/dvn/ Mainly take a look at the runDVN() function here: https://github.com/ProjectDVN/dvn/blob/main/source/dvn/package.d And just implement something similar to that which uses Application. Views etc. can be seen in the DVN documents on how to create and use. https://dvn-docs.readthedocs.io/en/latest/custom-views.html For components just see: https://github.com/ProjectDVN/dvn/tree/main/source/dvn/components DVN specifically uses SDL2 also. Disclaimer: I am the creator of DVN, so if you need help with it let me know here, but it should be straightforward.
Feb 19
On Wednesday, 19 February 2025 at 15:21:19 UTC, Danny Arends wrote:I've tried several different bindings to IMgui, however, none seem to work and seem abandoned to me (the most recent updated one 'bindbc-imgui' was updated 3 years ago).Actually, I have been working on an update to BindBC-ImGui for a long time. It now directly interfaces with ImGui's C++ API. It's 99% finished, I just have a few bug bears to sort out before I release it. You can clone the most recent version [from here](https://github.com/ichordev/bindbc-imgui) and use `dub add-local ./bindbc-imgui 1.0.0` on it so that dub knows where it is. Then in your dub recipe, add `bindbc-imgui` version `~>1.0` to `dependencies`, set its sub-configuration to `static-SDL2-Vulkan`, and add `imgui` to your `libs`. You will have to build Dear ImGui as a library, including any backends you want. Here's an example with the SDL2 backend & clang: ```sh mkdir build cd build clang++ -c -g -fPIC -std=c++11 -I../ -I/path/to/SDL2 -I/usr/local/include/ ../imgui*.cpp \ ../backends/imgui_impl_sdl2.cpp clang++ -fPIC -std=c++11 -shared -o libimgui.so imgui.o imgui_demo.o imgui_draw.o imgui_tables.o imgui_widgets.o imgui_impl_sdl2.o -lSDL2 ``` I've had weird linker issues when building Dear ImGui as a static library, so I recommend trying to build it as a shared library to start off with.But this got me wondering, what is the state of the art GUI library in D, when I am using modern OpenGL or Vulkan? Does anyone have any tips or tricks on how to achieve a basic GUI ? (without writing yet another GUI library binding from scratch)There isn't one, unfortunately. I've done some work on an API for one, but hit a few snags, so it's not the top of my priorities right now. [Fluid](https://code.dlang.org/packages/fluid) looks like a pretty good option if you want a native D library, but you would have to write an SDL/Vulkan backend for it, since it only comes with a Raylib 5 backend. It's more of a serious GUI library than Dear ImGui though.
Feb 19
On Thursday, 20 February 2025 at 06:53:26 UTC, IchorDev wrote:On Wednesday, 19 February 2025 at 15:21:19 UTC, Danny Arends wrote:Thanks, Running into some weird linker issues within bindbc.common.codegen: ``` /usr/bin/ld: /home/danny/.dub/cache/betterct/~master/build/betterC-debug-gZx8lRyN8EaQ6hq_UuhHCw/betterct.o:(.data._D39TypeInfo_S6bindbc6common7codegen6F Bind6__initZ+0x30): undefined reference to `_D6bindbc6common7codegen6FnBind9__xtoHashFNbNeKxSQBvQBrQBnQBiZm' /usr/bin/ld: /home/danny/.dub/cache/betterct/~master/build/betterC-debug-gZx8lRyN8EaQ6hq_UuhHCw/betterct.o:(.data._D39TypeInfo_S6bindbc6common7codegen6F Bind6__initZ+0x38): undefined reference to `_D6bindbc6common7codegen6FnBind11__xopEqualsMxFKxSQBwQBsQBoQBjZb' ``` while the individual components seem to build without issue: ``` Building bindbc-common 1.0.5: building configuration [yesBC] Building bindbc-loader 1.1.5: building configuration [yesBC] Building bindbc-imgui ~master: building configuration [dynamic] Building bindbc-sdl 1.5.2: building configuration [dynamicBC] ```I've tried several different bindings to IMgui, however, none seem to work and seem abandoned to me (the most recent updated one 'bindbc-imgui' was updated 3 years ago).Actually, I have been working on an update to BindBC-ImGui for a long time. It now directly interfaces with ImGui's C++ API. It's 99% finished, I just have a few bug bears to sort out before I release it. You can clone the most recent version [from here](https://github.com/ichordev/bindbc-imgui) and use `dub add-local ./bindbc-imgui 1.0.0` on it so that dub knows where it is. Then in your dub recipe, add `bindbc-imgui` version `~>1.0` to `dependencies`, set its sub-configuration to `static-SDL2-Vulkan`, and add `imgui` to your `libs`. You will have to build Dear ImGui as a library, including any backends you want. Here's an example with the SDL2 backend & clang: ```sh mkdir build cd build clang++ -c -g -fPIC -std=c++11 -I../ -I/path/to/SDL2 -I/usr/local/include/ ../imgui*.cpp \ ../backends/imgui_impl_sdl2.cpp clang++ -fPIC -std=c++11 -shared -o libimgui.so imgui.o imgui_demo.o imgui_draw.o imgui_tables.o imgui_widgets.o imgui_impl_sdl2.o -lSDL2 ``` I've had weird linker issues when building Dear ImGui as a static library, so I recommend trying to build it as a shared library to start off with.But this got me wondering, what is the state of the art GUI library in D, when I am using modern OpenGL or Vulkan? Does anyone have any tips or tricks on how to achieve a basic GUI ? (without writing yet another GUI library binding from scratch)There isn't one, unfortunately. I've done some work on an API for one, but hit a few snags, so it's not the top of my priorities right now. [Fluid](https://code.dlang.org/packages/fluid) looks like a pretty good option if you want a native D library, but you would have to write an SDL/Vulkan backend for it, since it only comes with a Raylib 5 backend. It's more of a serious GUI library than Dear ImGui though.
Feb 20
On Thursday, 20 February 2025 at 10:05:13 UTC, Danny Arends wrote:Running into some weird linker issues within bindbc.common.codegen: ``` /usr/bin/ld: /home/danny/.dub/cache/betterct/~master/build/betterC-debug-gZx8lRyN8EaQ6hq_UuhHCw/betterct.o:(.data._D39TypeInfo_S6bindbc6common7codegen6F Bind6__initZ+0x30): undefined reference to `_D6bindbc6common7codegen6FnBind9__xtoHashFNbNeKxSQBvQBrQBnQBiZm' /usr/bin/ld: /home/danny/.dub/cache/betterct/~master/build/betterC-debug-gZx8lRyN8EaQ6hq_UuhHCw/betterct.o:(.data._D39TypeInfo_S6bindbc6common7codegen6F Bind6__initZ+0x38): undefined reference to `_D6bindbc6common7codegen6FnBind11__xopEqualsMxFKxSQBwQBsQBoQBjZb' ``` while the individual components seem to build without issue: ``` Building bindbc-common 1.0.5: building configuration [yesBC] Building bindbc-loader 1.1.5: building configuration [yesBC] Building bindbc-imgui ~master: building configuration [dynamic] Building bindbc-sdl 1.5.2: building configuration [dynamicBC] ```Sorry for the late response. I missed this post. I see that you are building everything with BetterC enabled except BindBC-ImGui. Mixing BetterC and DRuntime breaks everything. Using the `dynamicBC` configuration should fix your issue.
Jul 04
On Wednesday, 19 February 2025 at 15:21:19 UTC, Danny Arends wrote:Hey all, I am looking to integrate a GUI library like IMgui / Nuklear into my app that uses Vulkan within SDL2 for rendering so that it can run on Windows, Linux, and Android (https://github.com/DannyArends/CalderaD). I've tried several different bindings to IMgui, however, none seem to work and seem abandoned to me (the most recent updated one 'bindbc-imgui' was updated 3 years ago). For Nuklear, the most up2date package (bindbc-nuklear) seems to build, but doesn't provide a Vulkan back-end example so I'm kind of stuck with how I'm supposed to integrate it (I might make the effort to translate the C-code example provided in the https://github.com/Immediate-Mode-UI/Nuklear repository to D) But this got me wondering, what is the state of the art GUI library in D, when I am using modern OpenGL or Vulkan ? Does anyone have any tips or tricks on how to achieve a basic GUI ? (without writing yet another GUI library binding from scratch)i2d-imgui was updated recently. Do note that to use this package you’ll need a C++ compiler and CMake. Additionally we’ve chosen not to include any backends so you should copy the backends from imgui directly and translate them to D. Which should be mostly trivial to do. Additionally my SDL-D package provides bindings to SDL3.
Jul 08