Skip to content

Commit

Permalink
Removed local copy of all dependencies
Browse files Browse the repository at this point in the history
Removed local copy of all dependencies in favor of auto checkout. This should also reduce
user confusion and attempt to use ancient version of ImGui embedded in the repository.
  • Loading branch information
thedmd committed Jul 21, 2024
1 parent 4336be9 commit bd1924c
Show file tree
Hide file tree
Showing 59 changed files with 563 additions and 65,852 deletions.
27 changes: 11 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,37 @@ env:

jobs:
Windows:
runs-on: windows-2019
env:
VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Configure CMake
run: cmake -S examples -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

macOS:
runs-on: macos-latest

steps:
- name: Install Dependencies
run: |
brew install glfw3
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Configure CMake
run: cmake -S examples -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

Linux:
runs-on: ubuntu-latest

steps:
- name: Install Dependencies
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libglfw3-dev
- uses: actions/checkout@v2
sudo apt update
sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev libwayland-dev libxkbcommon-dev mesa-common-dev libgl1-mesa-dev
- name: Configure CMake
run: cmake -S examples -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

52 changes: 26 additions & 26 deletions crude_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,44 +147,44 @@ struct value
# undef CRUDE_MAX4
# undef CRUDE_MAX3
# undef CRUDE_MAX2
using storage_t = std::aligned_storage<max_size, max_align>::type;

static object* object_ptr( storage_t& storage) { return reinterpret_cast< object*>(&storage); }
static const object* object_ptr(const storage_t& storage) { return reinterpret_cast<const object*>(&storage); }
static array* array_ptr( storage_t& storage) { return reinterpret_cast< array*>(&storage); }
static const array* array_ptr(const storage_t& storage) { return reinterpret_cast<const array*>(&storage); }
static string* string_ptr( storage_t& storage) { return reinterpret_cast< string*>(&storage); }
static const string* string_ptr(const storage_t& storage) { return reinterpret_cast<const string*>(&storage); }
static boolean* boolean_ptr( storage_t& storage) { return reinterpret_cast< boolean*>(&storage); }
static const boolean* boolean_ptr(const storage_t& storage) { return reinterpret_cast<const boolean*>(&storage); }
static number* number_ptr( storage_t& storage) { return reinterpret_cast< number*>(&storage); }
static const number* number_ptr(const storage_t& storage) { return reinterpret_cast<const number*>(&storage); }
struct storage_t { alignas(max_align) unsigned char data[max_size]; };

static object* object_ptr( storage_t& storage) { return reinterpret_cast< object*>(storage.data); }
static const object* object_ptr(const storage_t& storage) { return reinterpret_cast<const object*>(storage.data); }
static array* array_ptr( storage_t& storage) { return reinterpret_cast< array*>(storage.data); }
static const array* array_ptr(const storage_t& storage) { return reinterpret_cast<const array*>(storage.data); }
static string* string_ptr( storage_t& storage) { return reinterpret_cast< string*>(storage.data); }
static const string* string_ptr(const storage_t& storage) { return reinterpret_cast<const string*>(storage.data); }
static boolean* boolean_ptr( storage_t& storage) { return reinterpret_cast< boolean*>(storage.data); }
static const boolean* boolean_ptr(const storage_t& storage) { return reinterpret_cast<const boolean*>(storage.data); }
static number* number_ptr( storage_t& storage) { return reinterpret_cast< number*>(storage.data); }
static const number* number_ptr(const storage_t& storage) { return reinterpret_cast<const number*>(storage.data); }

static type_t construct(storage_t& storage, type_t type)
{
switch (type)
{
case type_t::object: new (&storage) object(); break;
case type_t::array: new (&storage) array(); break;
case type_t::string: new (&storage) string(); break;
case type_t::boolean: new (&storage) boolean(); break;
case type_t::number: new (&storage) number(); break;
case type_t::object: new (storage.data) object(); break;
case type_t::array: new (storage.data) array(); break;
case type_t::string: new (storage.data) string(); break;
case type_t::boolean: new (storage.data) boolean(); break;
case type_t::number: new (storage.data) number(); break;
default: break;
}

return type;
}

static type_t construct(storage_t& storage, null) { (void)storage; return type_t::null; }
static type_t construct(storage_t& storage, object&& value) { new (&storage) object(std::forward<object>(value)); return type_t::object; }
static type_t construct(storage_t& storage, const object& value) { new (&storage) object(value); return type_t::object; }
static type_t construct(storage_t& storage, array&& value) { new (&storage) array(std::forward<array>(value)); return type_t::array; }
static type_t construct(storage_t& storage, const array& value) { new (&storage) array(value); return type_t::array; }
static type_t construct(storage_t& storage, string&& value) { new (&storage) string(std::forward<string>(value)); return type_t::string; }
static type_t construct(storage_t& storage, const string& value) { new (&storage) string(value); return type_t::string; }
static type_t construct(storage_t& storage, const char* value) { new (&storage) string(value); return type_t::string; }
static type_t construct(storage_t& storage, boolean value) { new (&storage) boolean(value); return type_t::boolean; }
static type_t construct(storage_t& storage, number value) { new (&storage) number(value); return type_t::number; }
static type_t construct(storage_t& storage, object&& value) { new (storage.data) object(std::forward<object>(value)); return type_t::object; }
static type_t construct(storage_t& storage, const object& value) { new (storage.data) object(value); return type_t::object; }
static type_t construct(storage_t& storage, array&& value) { new (storage.data) array(std::forward<array>(value)); return type_t::array; }
static type_t construct(storage_t& storage, const array& value) { new (storage.data) array(value); return type_t::array; }
static type_t construct(storage_t& storage, string&& value) { new (storage.data) string(std::forward<string>(value)); return type_t::string; }
static type_t construct(storage_t& storage, const string& value) { new (storage.data) string(value); return type_t::string; }
static type_t construct(storage_t& storage, const char* value) { new (storage.data) string(value); return type_t::string; }
static type_t construct(storage_t& storage, boolean value) { new (storage.data) boolean(value); return type_t::boolean; }
static type_t construct(storage_t& storage, number value) { new (storage.data) number(value); return type_t::number; }

static void destruct(storage_t& storage, type_t type)
{
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ v0.10.0 (WIP):
From this point ed::EndCreate() and ed::EndDelete() can only be called when
ed::BeginCreate() and ed::BeginDelete() calls were successful.

RESTRUCTURE:
Removed local copy of all dependencies in favor of auto checkout. This should also reduce
user confusion and attempt to use ancient version of ImGui embedded in the repository.

NEW: Canvas: Add example of zooming at fixed point (#270)

NEW: Editor: Add smooth zoom (#266)
Expand Down
12 changes: 5 additions & 7 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
cmake_minimum_required(VERSION 3.12)

project(imgui-node-editor)
project(imgui-node-editor-examples)

# Define IMGUI_NODE_EDITOR_ROOT_DIR pointing to project root directory
get_filename_component(IMGUI_NODE_EDITOR_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. ABSOLUTE CACHE)
get_filename_component(IMGUI_NODE_EDITOR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/.. ABSOLUTE CACHE)

# Enable solution folders in Visual Studio and Folders in Xcode
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Point CMake where to look for module files.
list(APPEND CMAKE_MODULE_PATH ${IMGUI_NODE_EDITOR_ROOT_DIR}/misc/cmake-modules)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Node editor use C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED YES)





# Macro that will configure an example application
macro(add_example_executable name)
project(${name})
Expand Down Expand Up @@ -132,3 +128,5 @@ add_subdirectory(simple-example)
add_subdirectory(widgets-example)
add_subdirectory(basic-interaction-example)
add_subdirectory(blueprints-example)

set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT blueprints-example)
79 changes: 14 additions & 65 deletions examples/application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set(_Application_Sources
include/application.h
source/application.cpp
source/entry_point.cpp
source/imgui_extra_keys.h
source/config.h.in
source/setup.h
source/platform.h
Expand All @@ -19,75 +18,25 @@ add_library(application STATIC)

target_include_directories(application PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

find_package(imgui REQUIRED)
find_package(stb_image REQUIRED)
find_package(ScopeGuard REQUIRED)
target_link_libraries(application PUBLIC imgui)
target_link_libraries(application PRIVATE stb_image ScopeGuard)

set(imgui_components)
if (WIN32)
list(APPEND _Application_Sources
source/imgui_impl_dx11.cpp
source/imgui_impl_dx11.h
source/imgui_impl_win32.cpp
source/imgui_impl_win32.h
)

set(_DXSDK_Dir ${IMGUI_NODE_EDITOR_ROOT_DIR}/external/DXSDK)
set(_DXSDK_Arch x86)
if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(_DXSDK_Arch x64)
endif()

add_library(dxerr STATIC ${_DXSDK_Dir}/src/dxerr.cpp)
target_include_directories(dxerr PUBLIC "${_DXSDK_Dir}/include")
set_property(TARGET dxerr PROPERTY FOLDER "external")

add_library(d3dx11 UNKNOWN IMPORTED)
set_target_properties(d3dx11 PROPERTIES
IMPORTED_LOCATION "${_DXSDK_Dir}/lib/${_DXSDK_Arch}/d3dx11.lib"
IMPORTED_LOCATION_DEBUG "${_DXSDK_Dir}/lib/${_DXSDK_Arch}/d3dx11d.lib"
INTERFACE_INCLUDE_DIRECTORIES "${_DXSDK_Dir}/include"
INTERFACE_LINK_LIBRARIES "$<$<CONFIG:Debug>:dxerr>"
)

target_link_libraries(application PRIVATE d3d11.lib d3dcompiler.lib d3dx11)
list(APPEND imgui_components win32 dx11)
target_link_libraries(application PRIVATE imgui::win32 imgui::dx11)
else()
find_package(OpenGL REQUIRED)
find_package(glfw3 3 REQUIRED)

if (APPLE)
target_link_libraries(application PRIVATE
"-framework CoreFoundation"
"-framework Cocoa"
"-framework IOKit"
"-framework CoreVideo"
)
endif()
find_package(glfw REQUIRED)
list(APPEND imgui_components glfw opengl3)
target_link_libraries(application PRIVATE imgui::glfw imgui::opengl3)
set(HAVE_GLFW3 YES)
endif()

if (OpenGL_FOUND)
set(HAVE_OPENGL YES)

target_include_directories(application PRIVATE ${OPENGL_INCLUDE_DIR})
target_link_libraries(application PRIVATE ${OPENGL_gl_LIBRARY})
list(APPEND _Application_Sources
source/imgui_impl_opengl3.cpp
source/imgui_impl_opengl3.h
source/imgui_impl_opengl3_loader.h
)
endif()

if (glfw3_FOUND)
set(HAVE_GLFW3 YES)
find_package(imgui REQUIRED COMPONENTS ${imgui_components})
find_package(stb REQUIRED COMPONENTS image)
target_link_libraries(application PUBLIC imgui)
target_link_libraries(application PRIVATE stb::image)

list(APPEND _Application_Sources
source/imgui_impl_glfw.cpp
source/imgui_impl_glfw.h
)
target_link_libraries(application PRIVATE
glfw
)
if (OpenGL_FOUND)
set(HAVE_OPENGL YES)
endif()

configure_file(
Expand All @@ -106,4 +55,4 @@ source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${_Application_Sources})

target_sources(application PRIVATE ${_Application_Sources})

set_property(TARGET application PROPERTY FOLDER "examples")
set_property(TARGET application PROPERTY FOLDER "lib")
56 changes: 31 additions & 25 deletions examples/application/source/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
# include "setup.h"
# include "platform.h"
# include "renderer.h"

extern "C" {
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_STATIC
#include "stb_image.h"
}

# include "stb_image.h"

Application::Application(const char* name)
: Application(name, 0, nullptr)
Expand Down Expand Up @@ -94,9 +88,8 @@ void Application::RecreateFontAtlas()
io.Fonts = IM_NEW(ImFontAtlas);

ImFontConfig config;
config.OversampleH = 4;
config.OversampleV = 4;
config.PixelSnapH = false;
config.PixelSnapH = true;
config.RasterizerDensity = m_Platform->GetFramebufferScale();

m_DefaultFont = io.Fonts->AddFontFromFileTTF("data/Play-Regular.ttf", 18.0f, &config);
m_HeaderFont = io.Fonts->AddFontFromFileTTF("data/Cuprum-Bold.ttf", 20.0f, &config);
Expand All @@ -113,29 +106,19 @@ void Application::Frame()

if (m_Platform->HasFramebufferScaleChanged())
{
m_Renderer->InvalidateResources();
RecreateFontAtlas();
m_Renderer->UpdateResources();
m_Platform->AcknowledgeFramebufferScaleChanged();
}

const float windowScale = m_Platform->GetWindowScale();
const float framebufferScale = m_Platform->GetFramebufferScale();

if (io.WantSetMousePos)
{
io.MousePos.x *= windowScale;
io.MousePos.y *= windowScale;
}

m_Platform->NewFrame();

// Don't touch "uninitialized" mouse position
if (io.MousePos.x > -FLT_MAX && io.MousePos.y > -FLT_MAX)
{
io.MousePos.x /= windowScale;
io.MousePos.y /= windowScale;
}
io.DisplaySize.x /= windowScale;
io.DisplaySize.y /= windowScale;
io.DisplaySize.x *= windowScale;
io.DisplaySize.y *= windowScale;

io.DisplayFramebufferScale.x = framebufferScale;
io.DisplayFramebufferScale.y = framebufferScale;
Expand Down Expand Up @@ -163,7 +146,30 @@ void Application::Frame()
// Rendering
m_Renderer->Clear(ImColor(32, 32, 32, 255));
ImGui::Render();
m_Renderer->RenderDrawData(ImGui::GetDrawData());

// Manually scale the draw data, because ImGui backends are not yet
// consistent in handling FramebufferScale
auto drawData = ImGui::GetDrawData();

drawData->DisplaySize.x *= framebufferScale;
drawData->DisplaySize.y *= framebufferScale;

for (int i = 0; i < drawData->CmdListsCount; i++)
{
auto& cmdList = drawData->CmdLists[i];
for (auto& vtx : cmdList->VtxBuffer)
{
vtx.pos.x *= framebufferScale;
vtx.pos.y *= framebufferScale;
}
}

drawData->ScaleClipRects(drawData->FramebufferScale);

drawData->FramebufferScale.x = 1.0f;
drawData->FramebufferScale.y = 1.0f;

m_Renderer->RenderDrawData(drawData);

m_Platform->FinishFrame();
}
Expand Down
Loading

0 comments on commit bd1924c

Please sign in to comment.