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 8d5d857
Show file tree
Hide file tree
Showing 57 changed files with 502 additions and 65,781 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,24 @@ jobs:
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
- 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
run: |
sudo apt-get update
sudo apt-get install -y libglfw3-dev
- uses: actions/checkout@v2
- 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}}

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
10 changes: 4 additions & 6 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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)
Expand All @@ -9,16 +9,12 @@ get_filename_component(IMGUI_NODE_EDITOR_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. ABSOLUT
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>"
)
list(APPEND imgui_components win32 dx11)
target_link_libraries(application PRIVATE imgui::win32 imgui::dx11)
#else()
find_package(glfw REQUIRED)
list(APPEND imgui_components glfw opengl3)
target_link_libraries(application PRIVATE imgui::glfw imgui::opengl3)
set(HAVE_GLFW3 YES)
endif()

target_link_libraries(application PRIVATE d3d11.lib d3dcompiler.lib d3dx11)
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()
endif()
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)

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)

list(APPEND _Application_Sources
source/imgui_impl_glfw.cpp
source/imgui_impl_glfw.h
)
target_link_libraries(application PRIVATE
glfw
)
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 /= windowScale;
drawData->DisplaySize.y /= windowScale;

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
65 changes: 0 additions & 65 deletions examples/application/source/imgui_extra_keys.h

This file was deleted.

Loading

0 comments on commit 8d5d857

Please sign in to comment.