Thread overview
Looking for a simple GUI library that works with Vulkan on SDL2
2 days ago
Danny Arends
2 days ago
ryuukk_
1 day ago
Danny Arends
1 day ago
Danny Arends
2 days ago
ryuukk_
1 day ago
bauss
1 day ago
IchorDev
1 day ago
Danny Arends
2 days ago

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)

2 days ago

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

import nk;

Then the examples are 1:1, C/D is the same

Stick to simplicity, and get rewarded for it

2 days ago

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

1 day ago

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.html

There'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.

1 day ago

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 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:

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 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.

1 day ago

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

import nk;

Then the examples are 1:1, C/D is the same

Stick to simplicity, and get rewarded for it

Thanks 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 ?

1 day ago
On 20/02/2025 10:58 PM, Danny Arends wrote:
> 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 it
> 
> Thanks 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 ?

That's not -betterC, that's ImportC, different feature.

This one has a similar report: https://github.com/dlang/dmd/issues/20470

1 day ago

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:

>

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 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:

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 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.

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_S6bindbc6common7codegen6FnBind6__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_S6bindbc6common7codegen6FnBind6__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]
1 day ago
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:
>> [...]
>
> That's not -betterC, that's ImportC, different feature.
>
> This one has a similar report: https://github.com/dlang/dmd/issues/20470


Right, I always get those 2 confused... I mean importC indeed :)