diff --git a/.gitmodules b/.gitmodules index 8d5ef90..0586f20 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,6 @@ -[submodule "dependencies/imgui"] - path = dependencies/imgui - url = https://github.com/ocornut/imgui.git - branch = docking [submodule "dependencies/resource_embedder"] path = dependencies/resource_embedder url = https://timerix.ddns.net/git/Timerix/resource_embedder.git +[submodule "dependencies/cimgui"] + path = dependencies/cimgui + url = https://github.com/cimgui/cimgui.git diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 9c63d3e..f5a2710 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -9,7 +9,7 @@ "includePath": [ "dependencies/include", "dependencies/include/SDL2", - "dependencies/imgui", + "dependencies/cimgui/imgui", "${default}" ], "cppStandard": "c++20" diff --git a/README.md b/README.md index a03d513..609be96 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A game engine or something, idk. ## Installation 1. **Clone the repository.** ```sh -git clone --recurse-submodules https://timerix.ddns.net/git/Timerix/ougge.git +git clone --recurse-submodules --depth 1 https://timerix.ddns.net/git/Timerix/ougge.git ``` 2. **Install [cbuild](https://timerix.ddns.net/git/Timerix/cbuild).** 3. **Install [SDL2](https://github.com/libsdl-org/SDL) and [SDL2_image](https://github.com/libsdl-org/SDL_image).** diff --git a/dependencies/cimgui b/dependencies/cimgui new file mode 160000 index 0000000..5ba6ea3 --- /dev/null +++ b/dependencies/cimgui @@ -0,0 +1 @@ +Subproject commit 5ba6ea3fc0b3901693f7982b878fa19bffd9c97b diff --git a/dependencies/cimgui.config b/dependencies/cimgui.config new file mode 100644 index 0000000..d5cab18 --- /dev/null +++ b/dependencies/cimgui.config @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +DEP_WORKING_DIR='dependencies/cimgui' +DEP_PRE_BUILD_COMMAND='' +if [[ "$TASK" = *_dbg ]]; then + DEP_BUILD_COMMAND='cbuild -c ../cimgui.project.config build_shared_lib_dbg' +else + DEP_BUILD_COMMAND='cbuild -c ../cimgui.project.config build_shared_lib' +fi +DEP_POST_BUILD_COMMAND='rm -f cbuild.log' +DEP_CLEAN_COMMAND='cbuild clean -c ../cimgui.project.config' +DEP_STATIC_OUT_FILES='' +case $OS in + WINDOWS) + DEP_DYNAMIC_OUT_FILES="../bin/cimgui.dll" + ;; + LINUX) + DEP_DYNAMIC_OUT_FILES="../bin/cimgui.so" + ;; + *) + error "operating system $OS has no configuration variants" + ;; +esac diff --git a/dependencies/imgui.project.config b/dependencies/cimgui.project.config old mode 100755 new mode 100644 similarity index 70% rename from dependencies/imgui.project.config rename to dependencies/cimgui.project.config index a767416..b09c01e --- a/dependencies/imgui.project.config +++ b/dependencies/cimgui.project.config @@ -1,8 +1,8 @@ #!/usr/bin/env bash -CBUILD_VERSION=2.1.2 +CBUILD_VERSION=2.2.1 CONFIG_VERSION=1 -PROJECT="imgui" +PROJECT="cimgui" CMP_C="gcc" CMP_CPP="g++" STD_C="c11" @@ -10,13 +10,14 @@ STD_CPP="c++11" WARN_C="-Wall -Wno-discarded-qualifiers -Wno-unused-parameter" WARN_CPP="-Wall -Wno-unused-parameter" SRC_C="" -SRC_CPP="imgui.cpp - imgui_demo.cpp - imgui_draw.cpp - imgui_tables.cpp - imgui_widgets.cpp - backends/imgui_impl_sdl2.cpp - backends/imgui_impl_sdlrenderer2.cpp" +SRC_CPP="imgui/imgui.cpp + imgui/imgui_demo.cpp + imgui/imgui_draw.cpp + imgui/imgui_tables.cpp + imgui/imgui_widgets.cpp + imgui/backends/imgui_impl_sdl2.cpp + imgui/backends/imgui_impl_sdlrenderer2.cpp + cimgui.cpp" # Directory with dependency configs. # See cbuild/example_dependency_configs @@ -31,20 +32,22 @@ ENABLED_DEPENDENCIES='' # └── profile/ - gcc *.gcda profiling info files OBJDIR="../obj" OUTDIR="../bin" -STATIC_LIB_FILE="lib$PROJECT.a" # header include directories -INCLUDE="-I. -I../include/SDL2" +INCLUDE="-I. -I./imgui -I../include/SDL2" +STATIC_LIB_FILE="$PROJECT.a" # OS-specific options case "$OS" in WINDOWS) - EXEC_FILE="$PROJECT.exe" - SHARED_LIB_FILE="lib$PROJECT.dll" + SHARED_LIB_FILE="$PROJECT.dll" + LINKER_LIBS="-L../precompiled/$OS-$ARCH -l:SDL2.dll" + DEFINE="-DIMGUI_API=__declspec(dllexport)" ;; LINUX) - EXEC_FILE="$PROJECT" - SHARED_LIB_FILE="lib$PROJECT.so" + SHARED_LIB_FILE="$PROJECT.so" + LINKER_LIBS="-lSDL2" + DEFINE="-DIMGUI_API=__attribute__((__visibility__(\"default\")))" ;; *) error "operating system $OS has no configuration variants" @@ -55,25 +58,25 @@ esac case "$TASK" in # creates shared library build_shared_lib) - C_ARGS="-O2 -fpic -flto -shared" + C_ARGS="-O2 -fpic -shared $DEFINE" CPP_ARGS="$C_ARGS" - LINKER_ARGS="$CPP_ARGS -Wl,-soname,$SHARED_LIB_FILE" + LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh POST_TASK_SCRIPT= ;; # creates shared library with debug symbols and no optimizations build_shared_lib_dbg) - C_ARGS="-O0 -g3 -fpic -shared" + C_ARGS="-O0 -g3 -fpic -shared $DEFINE" CPP_ARGS="$C_ARGS" - LINKER_ARGS="$CPP_ARGS -Wl,-soname,$SHARED_LIB_FILE" + LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh POST_TASK_SCRIPT= ;; # creates static library build_static_lib) - C_ARGS="-O2" + C_ARGS="-O2 $DEFINE" CPP_ARGS="$C_ARGS" PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh @@ -81,7 +84,7 @@ case "$TASK" in ;; # creates static library with debug symbols and no optimizations build_static_lib_dbg) - C_ARGS="-O0 -g3" + C_ARGS="-O0 -g3 $DEFINE" CPP_ARGS="$C_ARGS" PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh diff --git a/dependencies/imgui b/dependencies/imgui deleted file mode 160000 index 7b6314f..0000000 --- a/dependencies/imgui +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7b6314f47d2aaa3758cfeeca66af34f5c9309ca4 diff --git a/dependencies/imgui.config b/dependencies/imgui.config deleted file mode 100755 index 7c708b4..0000000 --- a/dependencies/imgui.config +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -DEP_WORKING_DIR='dependencies/imgui' -DEP_PRE_BUILD_COMMAND='' -if [[ "$TASK" = *_dbg ]]; then - DEP_BUILD_COMMAND='cbuild -c ../imgui.project.config build_static_lib_dbg' -else - DEP_BUILD_COMMAND='cbuild -c ../imgui.project.config build_static_lib' -fi -DEP_POST_BUILD_COMMAND='' -DEP_CLEAN_COMMAND='cbuild clean -c ../imgui.project.config' -DEP_STATIC_OUT_FILES='../bin/libimgui.a' -DEP_DYNAMIC_OUT_FILES='' diff --git a/dependencies/src-csharp.config b/dependencies/src-csharp.config index 23fe21a..ffa1c25 100755 --- a/dependencies/src-csharp.config +++ b/dependencies/src-csharp.config @@ -6,4 +6,7 @@ if [[ "$TASK" = *_dbg ]]; then fi DEP_BUILD_COMMAND=$"dotnet build src-csharp.sln -o bin -c $CS_CONFIGURATION" DEP_CLEAN_COMMAND='rm -rf bin obj' -DEP_OTHER_OUT_FILES='bin/Ougge.dll' +DEP_OTHER_OUT_FILES='bin/Ougge.dll + bin/Tomlyn.dll + bin/Hexa.NET.ImGui.dll + bin/HexaGen.Runtime.dll' diff --git a/project.config b/project.config index 140bd8a..6d7f8a0 100755 --- a/project.config +++ b/project.config @@ -15,7 +15,7 @@ SRC_CPP="$(find src -name '*.cpp')" # See cbuild/example_dependency_configs DEPENDENCY_CONFIGS_DIR='dependencies' # List of dependency config files in DEPENDENCY_CONFIGS_DIR separated by space. -ENABLED_DEPENDENCIES='precompiled resources imgui src-csharp' +ENABLED_DEPENDENCIES='precompiled resources cimgui src-csharp' # OBJDIR structure: # ├── objects/ - Compiled object files. Cleans on each call of build task @@ -27,7 +27,7 @@ OUTDIR="bin" STATIC_LIB_FILE="lib$PROJECT.a" # header include directories -INCLUDE="-I./dependencies/imgui -I./dependencies/include -I./dependencies/include/SDL2" +INCLUDE="-I./dependencies/cimgui/imgui -I./dependencies/include -I./dependencies/include/SDL2" # OS-specific options case "$OS" in diff --git a/src-csharp/ExampleComponent.cs b/src-csharp/ExampleComponent.cs index 77c5458..335a2ad 100644 --- a/src-csharp/ExampleComponent.cs +++ b/src-csharp/ExampleComponent.cs @@ -1,4 +1,5 @@ using System; +using Hexa.NET.ImGui; namespace Ougge; @@ -11,5 +12,8 @@ public class ExampleComponent : Component public override void Update(double deltaTime) { Console.WriteLine($"C# deltaTime {deltaTime} object id {Owner.Id}"); + ImGui.Begin("C# WINDOW"); + ImGui.Text("Hello from ExampleComponent!"); + ImGui.End(); } } \ No newline at end of file diff --git a/src-csharp/Ougge.csproj b/src-csharp/Ougge.csproj index 198e3b4..9ece1fb 100644 --- a/src-csharp/Ougge.csproj +++ b/src-csharp/Ougge.csproj @@ -6,5 +6,10 @@ disable enable embedded + true + + + +