-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
4,215 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[submodule "gdext/dear_bindings"] | ||
path = gdext/dear_bindings | ||
url = https://github.com/dearimgui/dear_bindings | ||
[submodule "gdext/imgui"] | ||
path = gdext/imgui | ||
url = https://github.com/ocornut/imgui | ||
[submodule "gdext/godot-cpp"] | ||
path = gdext/godot-cpp | ||
url = https://github.com/godotengine/godot-cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Godot; | ||
#if GODOT_PC | ||
using ImGuiNET; | ||
using System.Runtime.InteropServices; | ||
using System; | ||
|
||
namespace ImGuiGodot; | ||
|
||
public partial class ImGuiSync : GodotObject | ||
{ | ||
public static void SyncPtrs() | ||
{ | ||
GodotObject gd = Engine.GetSingleton("ImGuiGD"); | ||
long[] ptrs = (long[])gd.Call("GetImGuiPtrs", | ||
ImGui.GetVersion(), | ||
Marshal.SizeOf<ImGuiIO>(), | ||
Marshal.SizeOf<ImDrawVert>(), | ||
sizeof(ushort), | ||
sizeof(ushort) | ||
); | ||
|
||
if (ptrs.Length != 3) | ||
return; | ||
|
||
checked | ||
{ | ||
ImGui.SetCurrentContext((IntPtr)ptrs[0]); | ||
ImGui.SetAllocatorFunctions((IntPtr)ptrs[1], (IntPtr)ptrs[2]); | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Language: Cpp | ||
BasedOnStyle: Microsoft | ||
AccessModifierOffset: -4 | ||
AllowAllArgumentsOnNextLine: false | ||
AlignEscapedNewlines: Left | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BinPackArguments: false | ||
BinPackParameters: true | ||
PointerAlignment: Left | ||
|
||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterNamespace: false | ||
AfterExternBlock: false |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
cmake_minimum_required(VERSION 3.26) | ||
|
||
# using cmake for dev on Windows, scons for production builds | ||
|
||
# set up vcpkg | ||
if (WIN32) | ||
set(VCPKG_TARGET_TRIPLET x64-windows-static-md) | ||
endif() | ||
file(TO_CMAKE_PATH "$ENV{VCPKG_ROOT}" VCPKG_ROOT) | ||
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") | ||
|
||
project(imgui-godot-native CXX) | ||
|
||
if (NOT TARGET godot-cpp) | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
godot-cpp | ||
GIT_REPOSITORY https://github.com/godotengine/godot-cpp | ||
GIT_TAG 4.2 | ||
) | ||
FetchContent_MakeAvailable(godot-cpp) | ||
endif() | ||
|
||
find_package(freetype CONFIG REQUIRED) | ||
#find_package(unofficial-lunasvg CONFIG REQUIRED) | ||
|
||
add_library(imgui-godot-native SHARED) | ||
target_compile_features(imgui-godot-native PRIVATE cxx_std_20) | ||
target_compile_definitions(imgui-godot-native PUBLIC | ||
IMGUI_USER_CONFIG="imconfig-godot.h" | ||
IMGUI_ENABLE_FREETYPE | ||
# IMGUI_ENABLE_FREETYPE_LUNASVG | ||
IGN_EXPORT | ||
) | ||
|
||
if (MSVC) | ||
target_compile_options(godot-cpp PRIVATE "/MP") | ||
target_compile_options(imgui-godot-native PRIVATE "/MP") | ||
endif() | ||
|
||
add_subdirectory(src) | ||
|
||
target_sources(imgui-godot-native PRIVATE | ||
imgui/imgui.cpp | ||
imgui/imgui_demo.cpp | ||
imgui/imgui_draw.cpp | ||
imgui/imgui_tables.cpp | ||
imgui/imgui_widgets.cpp | ||
imgui/imgui.h | ||
imgui/misc/freetype/imgui_freetype.cpp | ||
imgui/misc/freetype/imgui_freetype.h | ||
include/imconfig-godot.h | ||
include/imgui-godot.h | ||
gen/imgui_bindings.gen.h | ||
gen/cimgui.cpp | ||
gen/cimgui.h | ||
) | ||
|
||
target_link_libraries(imgui-godot-native PUBLIC | ||
godot-cpp | ||
freetype | ||
# unofficial::lunasvg::lunasvg | ||
) | ||
|
||
target_include_directories(imgui-godot-native PRIVATE src imgui gen PUBLIC include) | ||
set_target_properties(imgui-godot-native PROPERTIES PUBLIC_HEADER "include/imconfig-godot.h;include/imgui-godot.h") | ||
|
||
if(WIN32) | ||
set_property(TARGET imgui-godot-native | ||
PROPERTY OUTPUT_NAME "libimgui-godot-native.windows.$<IF:$<CONFIG:Debug>,debug,release>.x86_64") | ||
elseif(APPLE) | ||
set_property(TARGET imgui-godot-native | ||
PROPERTY OUTPUT_NAME "imgui-godot-native.macos.$<IF:$<CONFIG:Debug>,debug,release>") | ||
set_target_properties(imgui-godot-native PROPERTIES SUFFIX "") | ||
endif() | ||
|
||
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../addons/imgui-godot") | ||
|
||
if(WIN32) | ||
install(TARGETS imgui-godot-native | ||
RUNTIME DESTINATION bin | ||
PUBLIC_HEADER DESTINATION include | ||
) | ||
elseif(APPLE) | ||
install(TARGETS imgui-godot-native | ||
DESTINATION bin/libimgui-godot-native.macos.$<IF:$<CONFIG:Debug>,debug,release>.framework | ||
PUBLIC_HEADER DESTINATION include | ||
) | ||
endif() | ||
install(FILES "${CMAKE_SOURCE_DIR}/imgui-godot-native.gdextension" | ||
DESTINATION . | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python | ||
from glob import glob | ||
from pathlib import Path | ||
|
||
env = SConscript("godot-cpp/SConstruct") | ||
env.Append(CPPDEFINES=['IMGUI_USER_CONFIG="\\"imconfig-godot.h\\""', "IGN_EXPORT"]) | ||
env.Append(CPPPATH=["src/", "imgui/", "include/", "gen/"]) | ||
env.Replace(CXXFLAGS=str(env["CXXFLAGS"]).replace("c++17", "c++20")) | ||
|
||
sources = Glob("src/*.cpp") + Glob("imgui/*.cpp") + Glob("gen/*.cpp") | ||
|
||
(extension_path,) = glob("proj/addons/*/*.gdextension") | ||
addon_path = Path(extension_path).parent | ||
project_name = Path(extension_path).stem | ||
|
||
config = "release" if env["target"] == "template_release" else "debug" | ||
|
||
libpath = env.get("LIBPATH", []) | ||
libs = [env["LIBS"]] | ||
|
||
windows = env["platform"] == "windows" | ||
linux = env["platform"] == "linux" | ||
|
||
if config == "release": | ||
if windows: | ||
env.Append(CPPDEFINES=["NDEBUG"]) | ||
|
||
if windows: | ||
triplet = "x64-windows-static" | ||
elif linux: | ||
triplet = "x64-linux" | ||
else: | ||
triplet = "arm64-osx" | ||
|
||
env.Append(CPPPATH=["imgui/misc/freetype/"]) | ||
env.Append(CPPPATH=[f"vcpkg_installed/{triplet}/include"]) | ||
env.Append(CPPDEFINES=["IMGUI_ENABLE_FREETYPE"]) #, "IMGUI_ENABLE_FREETYPE_LUNASVG"]) | ||
sources += Glob("imgui/misc/freetype/*.cpp") | ||
libpath += [f"vcpkg_installed/{triplet}/lib"] | ||
libs += [ | ||
"freetype", | ||
# "lunasvg", | ||
"bz2", | ||
"libpng16" if windows else "png16", | ||
"zlib" if windows else "z", | ||
"brotlidec", | ||
"brotlicommon", | ||
] | ||
|
||
if env["platform"] == "macos": | ||
library = env.SharedLibrary( | ||
"{0}/bin/lib{1}.{2}.{3}.framework/{1}.{2}.{3}".format( | ||
addon_path, | ||
project_name, | ||
env["platform"], | ||
config, | ||
), | ||
source=sources, | ||
LIBPATH=libpath, | ||
LIBS=libs, | ||
) | ||
else: | ||
library = env.SharedLibrary( | ||
"{}/bin/lib{}.{}.{}.{}{}".format( | ||
addon_path, | ||
project_name, | ||
env["platform"], | ||
config, | ||
env["arch"], | ||
env["SHLIBSUFFIX"], | ||
), | ||
source=sources, | ||
LIBPATH=libpath, | ||
LIBS=libs, | ||
) | ||
|
||
Default(library) |
Submodule dear_bindings
added at
0c3357
Oops, something went wrong.