From 1bb84d41d840e5783bd0a4892ba2c56b4aa291e5 Mon Sep 17 00:00:00 2001 From: Patrick Dawson Date: Wed, 17 Jan 2024 04:48:23 +0100 Subject: [PATCH] Remove obsolete stuff --- doc/cpp-demo/.clang-format | 14 ---- doc/cpp-demo/CMakeLists.txt | 62 ----------------- doc/cpp-demo/CMakePresets.json | 58 ---------------- doc/cpp-demo/MyGame/Button1.cs | 34 ---------- doc/cpp-demo/MyGame/MyGame.csproj | 19 ------ doc/cpp-demo/MyGame/MyGame.sln | 19 ------ doc/cpp-demo/MyGame/default_env.tres | 7 -- doc/cpp-demo/MyGame/demoext.gdextension | 12 ---- doc/cpp-demo/MyGame/icon.svg | 1 - doc/cpp-demo/MyGame/icon.svg.import | 37 ---------- doc/cpp-demo/MyGame/main.tscn | 20 ------ doc/cpp-demo/MyGame/project.godot | 36 ---------- doc/cpp-demo/README.md | 26 ------- doc/cpp-demo/src/CMakeLists.txt | 5 -- doc/cpp-demo/src/MyCppNode.cpp | 90 ------------------------- doc/cpp-demo/src/MyCppNode.h | 27 -------- doc/cpp-demo/src/main.cpp | 35 ---------- doc/cpp-demo/test/test.cpp | 10 --- doc/cpp-demo/vcpkg.json | 21 ------ 19 files changed, 533 deletions(-) delete mode 100644 doc/cpp-demo/.clang-format delete mode 100644 doc/cpp-demo/CMakeLists.txt delete mode 100644 doc/cpp-demo/CMakePresets.json delete mode 100644 doc/cpp-demo/MyGame/Button1.cs delete mode 100644 doc/cpp-demo/MyGame/MyGame.csproj delete mode 100644 doc/cpp-demo/MyGame/MyGame.sln delete mode 100644 doc/cpp-demo/MyGame/default_env.tres delete mode 100644 doc/cpp-demo/MyGame/demoext.gdextension delete mode 100644 doc/cpp-demo/MyGame/icon.svg delete mode 100644 doc/cpp-demo/MyGame/icon.svg.import delete mode 100644 doc/cpp-demo/MyGame/main.tscn delete mode 100644 doc/cpp-demo/MyGame/project.godot delete mode 100644 doc/cpp-demo/README.md delete mode 100644 doc/cpp-demo/src/CMakeLists.txt delete mode 100644 doc/cpp-demo/src/MyCppNode.cpp delete mode 100644 doc/cpp-demo/src/MyCppNode.h delete mode 100644 doc/cpp-demo/src/main.cpp delete mode 100644 doc/cpp-demo/test/test.cpp delete mode 100644 doc/cpp-demo/vcpkg.json diff --git a/doc/cpp-demo/.clang-format b/doc/cpp-demo/.clang-format deleted file mode 100644 index c6eaef4..0000000 --- a/doc/cpp-demo/.clang-format +++ /dev/null @@ -1,14 +0,0 @@ -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 diff --git a/doc/cpp-demo/CMakeLists.txt b/doc/cpp-demo/CMakeLists.txt deleted file mode 100644 index f1d1b05..0000000 --- a/doc/cpp-demo/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -cmake_minimum_required(VERSION 3.22) - -# 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(demoext CXX) - -# this fixes the godot-cpp build on macOS for some reason -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -if (NOT TARGET godot-cpp) - include(FetchContent) - FetchContent_Declare( - godot-cpp - GIT_REPOSITORY https://github.com/godotengine/godot-cpp - GIT_TAG master # watch out, something will break eventually - ) - FetchContent_MakeAvailable(godot-cpp) -endif() - -find_package(imgui CONFIG REQUIRED) -find_package(implot CONFIG REQUIRED) -find_package(imguizmo CONFIG REQUIRED) -find_package(freetype CONFIG REQUIRED) -find_package(GTest CONFIG REQUIRED) - -add_library(demoext SHARED) -add_subdirectory(src) - -target_link_libraries(demoext PUBLIC - godot-cpp - imgui::imgui - freetype - implot::implot - imguizmo::imguizmo - ) -target_include_directories(demoext PRIVATE src) -target_compile_features(demoext PRIVATE cxx_std_20) -target_compile_definitions(demoext PUBLIC IMGUI_DISABLE_INCLUDE_IMCONFIG_H) - -set_property(TARGET demoext PROPERTY OUTPUT_NAME "demoext.$,debug,release>") - -if (WIN32) - # avoid installing the .lib - install(TARGETS demoext RUNTIME DESTINATION bin) -else() - install(TARGETS demoext DESTINATION bin) -endif() - -enable_testing() -add_executable(demotest test/test.cpp) -target_include_directories(demotest PRIVATE src) -target_link_libraries(demotest PRIVATE GTest::gtest_main demoext) - -include(GoogleTest) -gtest_discover_tests(demotest) diff --git a/doc/cpp-demo/CMakePresets.json b/doc/cpp-demo/CMakePresets.json deleted file mode 100644 index b3fb25e..0000000 --- a/doc/cpp-demo/CMakePresets.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "version": 3, - "cmakeMinimumRequired": { - "major": 3, - "minor": 22, - "patch": 0 - }, - "configurePresets": [ - { - "name": "debug", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build.debug", - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", - "CMAKE_INSTALL_PREFIX": "MyGame", - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "release", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build.release", - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", - "CMAKE_INSTALL_PREFIX": "MyGame", - "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON" - } - }, - { - "name": "msvc.debug", - "generator": "Visual Studio 17 2022", - "architecture": "x64", - "binaryDir": "${sourceDir}/msvc.debug", - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", - "CMAKE_INSTALL_PREFIX": "MyGame", - "CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD": "ON", - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_CONFIGURATION_TYPES": "Debug" - } - }, - { - "name": "msvc.release", - "generator": "Visual Studio 17 2022", - "architecture": "x64", - "binaryDir": "${sourceDir}/msvc.release", - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", - "CMAKE_INSTALL_PREFIX": "MyGame", - "CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD": "ON", - "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_CONFIGURATION_TYPES": "RelWithDebInfo", - "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON" - } - } - ] -} \ No newline at end of file diff --git a/doc/cpp-demo/MyGame/Button1.cs b/doc/cpp-demo/MyGame/Button1.cs deleted file mode 100644 index 45e5bf7..0000000 --- a/doc/cpp-demo/MyGame/Button1.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Godot; -using ImGuiGodot; -using ImGuiNET; -using System; - -public partial class Button1 : Button -{ - private IntPtr _freeTypeBuilder = IntPtr.Zero; - - public override void _Ready() - { - Pressed += OnPressed; - } - - private void OnPressed() - { - ImGuiGD.ResetFonts(); - ImGuiGD.AddFont(GD.Load("res://Hack-Regular.ttf"), 18); - ImGuiGD.RebuildFontAtlas(); - - // toggle builder with each click - unsafe - { - ImFontAtlas* atlas = ImGui.GetIO().NativePtr->Fonts; - if (_freeTypeBuilder == IntPtr.Zero) - _freeTypeBuilder = (IntPtr)atlas->FontBuilderIO; - - if (atlas->FontBuilderIO == null) - atlas->FontBuilderIO = (IntPtr*)_freeTypeBuilder; - else - atlas->FontBuilderIO = null; - } - } -} diff --git a/doc/cpp-demo/MyGame/MyGame.csproj b/doc/cpp-demo/MyGame/MyGame.csproj deleted file mode 100644 index 54d88db..0000000 --- a/doc/cpp-demo/MyGame/MyGame.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - net6.0 - true - True - - - $(GodotDefineConstants);$(DefineConstants);IMGUI_GODOT_DEV - - - $(GodotDefineConstants);$(DefineConstants);IMGUI_GODOT_DEV - - - $(GodotDefineConstants);$(DefineConstants);IMGUI_GODOT_DEV - - - - - \ No newline at end of file diff --git a/doc/cpp-demo/MyGame/MyGame.sln b/doc/cpp-demo/MyGame/MyGame.sln deleted file mode 100644 index 07b6668..0000000 --- a/doc/cpp-demo/MyGame/MyGame.sln +++ /dev/null @@ -1,19 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyGame", "MyGame.csproj", "{3FFFFA7D-AD43-4770-AE3F-2BA38FF919E4}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - ExportDebug|Any CPU = ExportDebug|Any CPU - ExportRelease|Any CPU = ExportRelease|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3FFFFA7D-AD43-4770-AE3F-2BA38FF919E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3FFFFA7D-AD43-4770-AE3F-2BA38FF919E4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3FFFFA7D-AD43-4770-AE3F-2BA38FF919E4}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU - {3FFFFA7D-AD43-4770-AE3F-2BA38FF919E4}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU - {3FFFFA7D-AD43-4770-AE3F-2BA38FF919E4}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU - {3FFFFA7D-AD43-4770-AE3F-2BA38FF919E4}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU - EndGlobalSection -EndGlobal diff --git a/doc/cpp-demo/MyGame/default_env.tres b/doc/cpp-demo/MyGame/default_env.tres deleted file mode 100644 index 0645b88..0000000 --- a/doc/cpp-demo/MyGame/default_env.tres +++ /dev/null @@ -1,7 +0,0 @@ -[gd_resource type="Environment" load_steps=2 format=3 uid="uid://dtd3q2x2ulcsi"] - -[sub_resource type="Sky" id="1"] - -[resource] -background_mode = 2 -sky = SubResource("1") diff --git a/doc/cpp-demo/MyGame/demoext.gdextension b/doc/cpp-demo/MyGame/demoext.gdextension deleted file mode 100644 index 1ba5cf1..0000000 --- a/doc/cpp-demo/MyGame/demoext.gdextension +++ /dev/null @@ -1,12 +0,0 @@ -[configuration] - -entry_symbol = "demoext_init" - -[libraries] - -macos.debug = "res://bin/libdemoext.debug.dylib" -macos.release = "res://bin/libdemoext.release.dylib" -windows.debug.x86_64 = "res://bin/demoext.debug.dll" -windows.release.x86_64 = "res://bin/demoext.release.dll" -linux.debug.x86_64 = "res://bin/libdemoext.debug.so" -linux.release.x86_64 = "res://bin/libdemoext.release.so" diff --git a/doc/cpp-demo/MyGame/icon.svg b/doc/cpp-demo/MyGame/icon.svg deleted file mode 100644 index adc26df..0000000 --- a/doc/cpp-demo/MyGame/icon.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/doc/cpp-demo/MyGame/icon.svg.import b/doc/cpp-demo/MyGame/icon.svg.import deleted file mode 100644 index a43c953..0000000 --- a/doc/cpp-demo/MyGame/icon.svg.import +++ /dev/null @@ -1,37 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://d08m2uvixtsgf" -path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://icon.svg" -dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/bptc_ldr=0 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 -svg/scale=1.0 -editor/scale_with_editor_scale=false -editor/convert_colors_with_editor_theme=false diff --git a/doc/cpp-demo/MyGame/main.tscn b/doc/cpp-demo/MyGame/main.tscn deleted file mode 100644 index f0a20e4..0000000 --- a/doc/cpp-demo/MyGame/main.tscn +++ /dev/null @@ -1,20 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://d02ytucir7qh2"] - -[ext_resource type="Script" path="res://Button1.cs" id="1_sb8ai"] - -[node name="Control" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="MyCppNode" type="MyCppNode" parent="."] - -[node name="Button1" type="Button" parent="."] -layout_mode = 0 -offset_right = 132.0 -offset_bottom = 59.0 -text = "reload font" -script = ExtResource("1_sb8ai") diff --git a/doc/cpp-demo/MyGame/project.godot b/doc/cpp-demo/MyGame/project.godot deleted file mode 100644 index 02f9404..0000000 --- a/doc/cpp-demo/MyGame/project.godot +++ /dev/null @@ -1,36 +0,0 @@ -; Engine configuration file. -; It's best edited using the editor UI and not directly, -; since the parameters that go here are not all obvious. -; -; Format: -; [section] ; section goes between [] -; param=value ; assign values to parameters - -config_version=5 - -[application] - -config/name="MyGame" -run/main_scene="res://main.tscn" -config/features=PackedStringArray("4.0", "C#") -config/icon="res://icon.svg" - -[autoload] - -ImGuiLayer="*res://addons/imgui-godot/ImGuiLayer.tscn" - -[dotnet] - -project/assembly_name="MyGame" - -[editor_plugins] - -enabled=PackedStringArray("res://addons/imgui-godot/plugin.cfg") - -[native_extensions] - -paths=["res://demoext.gdextension"] - -[rendering] - -environment/defaults/default_environment="res://default_env.tres" diff --git a/doc/cpp-demo/README.md b/doc/cpp-demo/README.md deleted file mode 100644 index 2aca589..0000000 --- a/doc/cpp-demo/README.md +++ /dev/null @@ -1,26 +0,0 @@ - -A sample GDExtension using ImGui with a context from imgui-godot. Uses vcpkg and CMake for easy setup and fast builds. - -## Windows (MSVC) -``` -cmake --preset msvc.debug -cmake --build msvc.debug --config Debug --target install - -cmake --preset msvc.release -cmake --build msvc.release --config RelWithDebInfo --target install -``` - -## macOS -``` -cmake --preset debug -cmake --build build.debug --target install - -cmake --preset release -cmake --build build.release --target install -``` - -TODO: fonts with FreeType - -TODO: macOS frameworks instead of plain dylibs - -TODO: Linux? almost works but Godot fails to load the .so, missing symbol diff --git a/doc/cpp-demo/src/CMakeLists.txt b/doc/cpp-demo/src/CMakeLists.txt deleted file mode 100644 index 40ba80d..0000000 --- a/doc/cpp-demo/src/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -target_sources(demoext PRIVATE - main.cpp - MyCppNode.cpp - MyCppNode.h -) diff --git a/doc/cpp-demo/src/MyCppNode.cpp b/doc/cpp-demo/src/MyCppNode.cpp deleted file mode 100644 index 5c6d99f..0000000 --- a/doc/cpp-demo/src/MyCppNode.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "MyCppNode.h" -#include -#include -#include -#include -#include -#include -using namespace godot; - -struct MyCppNode::Impl -{ - bool show_imgui_demo = true; - bool show_implot_demo = true; -}; - -MyCppNode::MyCppNode() : impl(std::make_unique()) -{ -} - -MyCppNode::~MyCppNode() -{ -} - -void MyCppNode::_bind_methods() -{ -} - -void MyCppNode::_ready() -{ - set_process(false); -#ifdef DEBUG_ENABLED - if (Engine::get_singleton()->is_editor_hint()) - return; -#endif - - Node* igl = get_node_or_null("/root/ImGuiLayer"); - if (!igl) - { - UtilityFunctions::push_error("couldn't get /root/ImGuiLayer"); - return; - } - - Variant rv = igl->call("GetImGuiPtrs", - ImGui::GetVersion(), - static_cast(sizeof(ImGuiIO)), - static_cast(sizeof(ImDrawVert)), - static_cast(sizeof(ImDrawIdx))); - - if (!rv) - { - UtilityFunctions::push_error("GetImGuiPtrs failed"); - return; - } - - PackedInt64Array imgui_ptrs = rv; - - if (imgui_ptrs.size() < 3) - return; - - int64_t ctx = imgui_ptrs[0]; - int64_t mem_alloc = imgui_ptrs[1]; - int64_t mem_free = imgui_ptrs[2]; - - ImGui::SetCurrentContext((ImGuiContext*)ctx); - ImGui::SetAllocatorFunctions((ImGuiMemAllocFunc)mem_alloc, (ImGuiMemFreeFunc)mem_free); - - // will be used in the next RebuildFontAtlas - ImGui::GetIO().Fonts->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType(); - - ImPlot::CreateContext(); - set_process(true); -} - -void MyCppNode::_exit_tree() -{ - ImPlot::DestroyContext(); -} - -void MyCppNode::_process(double delta) -{ - if (impl->show_imgui_demo) - ImGui::ShowDemoWindow(&impl->show_imgui_demo); - - if (impl->show_implot_demo) - ImPlot::ShowDemoWindow(&impl->show_implot_demo); - - ImGui::Begin("Cpp Window"); - ImGui::Text("hello from C++"); - ImGui::End(); -} diff --git a/doc/cpp-demo/src/MyCppNode.h b/doc/cpp-demo/src/MyCppNode.h deleted file mode 100644 index 5cdf94e..0000000 --- a/doc/cpp-demo/src/MyCppNode.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include -#include - -using godot::InputEvent; -using godot::Node; -using godot::Ref; - -class MyCppNode : public Node -{ - GDCLASS(MyCppNode, Node); - -protected: - static void _bind_methods(); - -public: - void _ready() override; - void _exit_tree() override; - void _process(double delta) override; - - MyCppNode(); - ~MyCppNode(); - -private: - struct Impl; - std::unique_ptr impl; -}; diff --git a/doc/cpp-demo/src/main.cpp b/doc/cpp-demo/src/main.cpp deleted file mode 100644 index 0806f59..0000000 --- a/doc/cpp-demo/src/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "MyCppNode.h" -#include -#include -#include - -using namespace godot; - -void initialize_demo_module(ModuleInitializationLevel p_level) -{ - if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) - return; - - ClassDB::register_class(); -} - -void uninitialize_demo_module(ModuleInitializationLevel p_level) -{ - if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) - return; -} - -extern "C" { -GDNativeBool GDN_EXPORT demoext_init(const GDNativeInterface* p_interface, - const GDNativeExtensionClassLibraryPtr p_library, - GDNativeInitialization* r_initialization) -{ - godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization); - - init_obj.register_initializer(initialize_demo_module); - init_obj.register_terminator(uninitialize_demo_module); - init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); - - return init_obj.init(); -} -} diff --git a/doc/cpp-demo/test/test.cpp b/doc/cpp-demo/test/test.cpp deleted file mode 100644 index edf9dc8..0000000 --- a/doc/cpp-demo/test/test.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "MyCppNode.h" -#include -#include - -// make a Godot test runner, or just test modular game logic here - -TEST(GameLogicTests, DoStuff) -{ - ASSERT_TRUE(true); -} diff --git a/doc/cpp-demo/vcpkg.json b/doc/cpp-demo/vcpkg.json deleted file mode 100644 index b2ee4d4..0000000 --- a/doc/cpp-demo/vcpkg.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "dependencies": [ - { - "name": "imgui", - "features": [ - "docking-experimental", - "freetype" - ] - }, - "implot", - "imguizmo", - "gtest" - ], - "builtin-baseline": "6f7ffeb18f99796233b958aaaf14ec7bd4fb64b2", - "overrides": [ - { - "name": "imgui", - "version": "1.88" - } - ] -} \ No newline at end of file