From c612bb6fb1ccd4cd6a89e927b78537e65a68ba69 Mon Sep 17 00:00:00 2001 From: Juna <46632782+JunaMeinhold@users.noreply.github.com> Date: Thu, 8 Aug 2024 01:37:05 +0200 Subject: [PATCH 01/10] Update README.md --- README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 61d8ffb..a424517 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Hexa.NET.ImGui -Hexa.NET.ImGui is a .NET wrapper for the Dear ImGui (1.90.9) library, including support for internal components and popular addons like ImGuizmo, ImNodes, and ImPlot. This wrapper allows developers to leverage the powerful and flexible Dear ImGui library within the .NET ecosystem. +Welcome to Hexa.NET.ImGui! This custom wrapper is designed to be a high-performance, API-compatible alternative to ImGuiNET, offering enhanced speed, additional functionality, and comprehensive access to ImGui's internal structures. With optimizations that bring near C performance and significantly reduced startup times, Hexa.NET.ImGui provides the best of both worlds: the power of C and the productivity of C#. ## Features @@ -12,6 +12,7 @@ Hexa.NET.ImGui is a .NET wrapper for the Dear ImGui (1.90.9) library, including - **Access to Internals**: Allows users to access Dear ImGui internals for advanced customization and functionality. - **Drop in replacement for ImGuiNET** Adapt to the library with minimal effort by simply changing the namespace. - **High performance** Using a static VTable, all API calls are faster and startup time is reduced. +- **Optimized String Handling**: Overloads that bypass UTF-8 encoding and avoid allocations. ## Packages @@ -64,6 +65,33 @@ For a comprehensive example of how to use the library, refer to the [ExampleD3D1 For details on how to set up the library, check the [ImGuiManager.cs](https://github.com/HexaEngine/Hexa.NET.ImGui/blob/master/ExampleD3D11/ImGuiDemo/ImGuiManager.cs) file in the ExampleD3D11 project. +### Using the Flexible and Optimized API + +Hexa.NET.ImGui supports both safe and unsafe API calls, along with optimized string handling to bypass UTF-8 encoding and avoid allocations. Here are some examples: + + 1. Safe API Call: + +```cs +ImGui.Text("A normal C# string"); +``` + + 2. Unsafe API Call: +```cs +unsafe +{ + byte* pText = (byte*)Marshal.StringToHGlobalAnsi("A string from an unsafe pointer").ToPointer(); + ImGui.Text(pText); + Marshal.FreeHGlobal((IntPtr)pText); +} +``` + + 3. Optimized String Handling: +```cs +ImGui.Text("A C# string"u8); +``` +**This overload bypasses UTF-8 encoding and avoids allocations, providing a highly optimized way to render text.** + + ## Projects Using Hexa.NET.ImGui From 7563fc8f014b6b8f402af18af9e31411b057d9a8 Mon Sep 17 00:00:00 2001 From: Juna <46632782+JunaMeinhold@users.noreply.github.com> Date: Sat, 10 Aug 2024 13:29:00 +0200 Subject: [PATCH 02/10] Create cimgui-cmake-dbg.yml --- .github/workflows/cimgui-cmake-dbg.yml | 71 ++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/cimgui-cmake-dbg.yml diff --git a/.github/workflows/cimgui-cmake-dbg.yml b/.github/workflows/cimgui-cmake-dbg.yml new file mode 100644 index 0000000..0f6ed1d --- /dev/null +++ b/.github/workflows/cimgui-cmake-dbg.yml @@ -0,0 +1,71 @@ +name: Build cimgui Libraries (Debug config) + +on: [workflow_dispatch] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + arch: x86_64 + - os: ubuntu-latest + arch: arm64 + - os: windows-latest + arch: x86_64 + - os: windows-latest + arch: x86 + - os: windows-latest + arch: arm64 + - os: macos-latest + arch: x86_64 + - os: macos-latest + arch: arm64 + steps: + - uses: actions/checkout@v4.1.7 + with: + repository: 'cimgui/cimgui' + path: 'cimgui' + submodules: true + + - name: Install dependencies on Ubuntu + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake + + - name: Install dependencies on macOS + if: matrix.os == 'macos-latest' + run: | + brew update + brew install cmake + + - name: Install dependencies on Windows + if: matrix.os == 'windows-latest' + run: | + choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' + + - name: Configure cimgui with CMake for macOS ARM64 + if: matrix.arch == 'arm64' && matrix.os == 'macos-latest' + run: cmake -S cimgui -B cimgui/build -DCMAKE_OSX_ARCHITECTURES=arm64 + + - name: Configure cimgui with CMake + if: matrix.arch != 'arm64' || matrix.os != 'macos-latest' + run: cmake -S cimgui -B cimgui/build + + - name: Build cimgui + run: cmake --build cimgui/build --config Debug + + - name: Upload Artifacts + uses: actions/upload-artifact@v4.3.4 + with: + name: ${{ matrix.os }}-${{ matrix.arch }}-artifacts + path: | + cimgui/build/Debug/*.dll + cimgui/build/Debug/*.pbd + cimgui/build/*.so + cimgui/build/*.pdb + cimgui/build/*.dylib + cimgui/build/*.pdb + if-no-files-found: ignore # 'warn' or 'ignore' or 'error' From a6dc33ccd6a7f4cc7317b29d4c0f5b743918ea32 Mon Sep 17 00:00:00 2001 From: Juna <46632782+JunaMeinhold@users.noreply.github.com> Date: Sat, 10 Aug 2024 13:41:37 +0200 Subject: [PATCH 03/10] Create cimgui-android-cmake.yml --- .github/workflows/cimgui-android-cmake.yml | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/cimgui-android-cmake.yml diff --git a/.github/workflows/cimgui-android-cmake.yml b/.github/workflows/cimgui-android-cmake.yml new file mode 100644 index 0000000..4197da7 --- /dev/null +++ b/.github/workflows/cimgui-android-cmake.yml @@ -0,0 +1,71 @@ +name: Build cimgui Libraries + +on: [workflow_dispatch] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + arch: x86_64 + steps: + - uses: actions/checkout@v4.1.7 + with: + repository: 'cimgui/cimgui' + path: 'cimgui' + submodules: true + + - name: Install dependencies on Ubuntu + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Android SDK + uses: android-actions/setup-android@v2.0.10 + + - name: Install Android NDK + run: sdkmanager --install "ndk-bundle" + + - name: Build for arm64-v8a + run: | + cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SYSTEM_NAME=Android \ + -DCMAKE_ANDROID_NDK=$ANDROID_NDK_HOME \ + -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \ + -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang \ + -DCMAKE_ANDROID_STL_TYPE=c++_shared \ + -DCMAKE_ANDROID_API=21 \ + -S cimgui \ + -B cimgui/build/arm64-v8a + cmake --build cimgui/build/arm64-v8a --config Release + + - name: Build for x86_64 + run: | + cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SYSTEM_NAME=Android \ + -DCMAKE_ANDROID_NDK=$ANDROID_NDK_HOME \ + -DCMAKE_ANDROID_ARCH_ABI=x86_64 \ + -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang \ + -DCMAKE_ANDROID_STL_TYPE=c++_shared \ + -DCMAKE_ANDROID_API=21 \ + -S cimgui \ + -B cimgui/build/x86_64 + cmake --build cimgui/build/x86_64 --config Release + + - name: Upload Artifacts + uses: actions/upload-artifact@v4.3.4 + with: + name: ${{ matrix.os }}-${{ matrix.arch }}-artifacts + path: | + cimgui/build/arm64-v8a/*.so + cimgui/build/x86_64/*.so + if-no-files-found: ignore # 'warn' or 'ignore' or 'error' From c7087cf0907907a6401919f37447dd65a5fe28f9 Mon Sep 17 00:00:00 2001 From: Juna <46632782+JunaMeinhold@users.noreply.github.com> Date: Sat, 10 Aug 2024 13:41:56 +0200 Subject: [PATCH 04/10] Update cimgui-android-cmake.yml --- .github/workflows/cimgui-android-cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cimgui-android-cmake.yml b/.github/workflows/cimgui-android-cmake.yml index 4197da7..1d18144 100644 --- a/.github/workflows/cimgui-android-cmake.yml +++ b/.github/workflows/cimgui-android-cmake.yml @@ -1,4 +1,4 @@ -name: Build cimgui Libraries +name: Build cimgui Libraries (Android) on: [workflow_dispatch] From 9bf74fe3dd07dcfbe39a08bbc4c2a40e45343638 Mon Sep 17 00:00:00 2001 From: Juna <46632782+JunaMeinhold@users.noreply.github.com> Date: Sat, 10 Aug 2024 13:44:31 +0200 Subject: [PATCH 05/10] Update cimgui-android-cmake.yml --- .github/workflows/cimgui-android-cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cimgui-android-cmake.yml b/.github/workflows/cimgui-android-cmake.yml index 1d18144..5f2f8bc 100644 --- a/.github/workflows/cimgui-android-cmake.yml +++ b/.github/workflows/cimgui-android-cmake.yml @@ -21,7 +21,7 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update - sudo apt-get install -y build-essential cmake + sudo apt-get install -y build-essential cmake ninja-build - name: Setup Java uses: actions/setup-java@v3 From 91ef9ea6c0e2c469c6388280d0a8d6869a501926 Mon Sep 17 00:00:00 2001 From: Juna <46632782+JunaMeinhold@users.noreply.github.com> Date: Sat, 10 Aug 2024 14:17:18 +0200 Subject: [PATCH 06/10] Update cimgui-cmake-dbg.yml --- .github/workflows/cimgui-cmake-dbg.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cimgui-cmake-dbg.yml b/.github/workflows/cimgui-cmake-dbg.yml index 0f6ed1d..1beb890 100644 --- a/.github/workflows/cimgui-cmake-dbg.yml +++ b/.github/workflows/cimgui-cmake-dbg.yml @@ -62,10 +62,6 @@ jobs: with: name: ${{ matrix.os }}-${{ matrix.arch }}-artifacts path: | - cimgui/build/Debug/*.dll - cimgui/build/Debug/*.pbd - cimgui/build/*.so - cimgui/build/*.pdb - cimgui/build/*.dylib - cimgui/build/*.pdb + cimgui/build/Debug/*.{dll,pbd} + cimgui/build/*.{so,pdb,dylib} if-no-files-found: ignore # 'warn' or 'ignore' or 'error' From 3f043d16492c4adbe12d20cbb6776f95f7bf883b Mon Sep 17 00:00:00 2001 From: Juna <46632782+JunaMeinhold@users.noreply.github.com> Date: Sat, 10 Aug 2024 14:25:12 +0200 Subject: [PATCH 07/10] Update cimgui-cmake-dbg.yml --- .github/workflows/cimgui-cmake-dbg.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cimgui-cmake-dbg.yml b/.github/workflows/cimgui-cmake-dbg.yml index 1beb890..8900851 100644 --- a/.github/workflows/cimgui-cmake-dbg.yml +++ b/.github/workflows/cimgui-cmake-dbg.yml @@ -62,6 +62,5 @@ jobs: with: name: ${{ matrix.os }}-${{ matrix.arch }}-artifacts path: | - cimgui/build/Debug/*.{dll,pbd} - cimgui/build/*.{so,pdb,dylib} + cimgui/build/ if-no-files-found: ignore # 'warn' or 'ignore' or 'error' From 7c0e143a5d4a3739ab5fc74e95037503862c8065 Mon Sep 17 00:00:00 2001 From: Juna <46632782+JunaMeinhold@users.noreply.github.com> Date: Sun, 11 Aug 2024 19:02:11 +0200 Subject: [PATCH 08/10] Update ImGuiSDL2Platform.cs --- ExampleFramework/ImGuiDemo/ImGuiSDL2Platform.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ExampleFramework/ImGuiDemo/ImGuiSDL2Platform.cs b/ExampleFramework/ImGuiDemo/ImGuiSDL2Platform.cs index 032db12..a5f2357 100644 --- a/ExampleFramework/ImGuiDemo/ImGuiSDL2Platform.cs +++ b/ExampleFramework/ImGuiDemo/ImGuiSDL2Platform.cs @@ -519,7 +519,7 @@ public static unsafe void Shutdown() if (bd->ClipboardTextData != null) sdl.Free(bd->ClipboardTextData); for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor.Count; cursor_n++) - sdl.Free(bd->MouseCursors[(int)cursor_n]); + sdl.FreeCursor(bd->MouseCursors[(int)cursor_n]); Free(bd->MouseCursors); CloseGamepads(); @@ -1051,4 +1051,4 @@ private static void ShutdownPlatformInterface() ImGui.DestroyPlatformWindows(); } } -} \ No newline at end of file +} From 9efbe7ddc9e99e591211ecba1a6b0bf50308d1e2 Mon Sep 17 00:00:00 2001 From: Juna <46632782+JunaMeinhold@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:56:27 +0200 Subject: [PATCH 09/10] Update README.md --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index a424517..8bea814 100644 --- a/README.md +++ b/README.md @@ -99,11 +99,6 @@ ImGui.Text("A C# string"u8); HexaEngine Editor -## TODO - -- **Refactor the generator**: Improve the code generation process for better performance and maintainability. -- **More demos**: Add additional demo applications to showcase various features and use cases. - ## Screenshots ### Main Interface From e131df7456db3b705946d612ee75e27163d33eea Mon Sep 17 00:00:00 2001 From: Juna <46632782+JunaMeinhold@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:08:59 +0200 Subject: [PATCH 10/10] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8bea814..8a918ed 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Welcome to Hexa.NET.ImGui! This custom wrapper is designed to be a high-performance, API-compatible alternative to ImGuiNET, offering enhanced speed, additional functionality, and comprehensive access to ImGui's internal structures. With optimizations that bring near C performance and significantly reduced startup times, Hexa.NET.ImGui provides the best of both worlds: the power of C and the productivity of C#. +#### The code generator in use [HexaGen](https://github.com/HexaEngine/HexaGen). + ## Features - **Comprehensive Wrapper**: Integrates the core Dear ImGui library along with essential addons such as ImGuizmo, ImNodes, and ImPlot.