Skip to content

Commit 8d5d857

Browse files
committed
Removed local copy of all dependencies
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.
1 parent 4336be9 commit 8d5d857

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+502
-65781
lines changed

.github/workflows/build.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,24 @@ jobs:
3131
run: cmake -S examples -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
3232
- name: Build
3333
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
34-
34+
3535
macOS:
3636
runs-on: macos-latest
3737

3838
steps:
39-
- name: Install Dependencies
40-
run: |
41-
brew install glfw3
4239
- uses: actions/checkout@v2
4340
- name: Configure CMake
4441
run: cmake -S examples -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
4542
- name: Build
4643
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
47-
44+
4845
Linux:
4946
runs-on: ubuntu-latest
5047

5148
steps:
52-
- name: Install Dependencies
53-
run: |
54-
sudo apt-get update
55-
sudo apt-get install -y libglfw3-dev
5649
- uses: actions/checkout@v2
5750
- name: Configure CMake
5851
run: cmake -S examples -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
5952
- name: Build
6053
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
61-
54+

docs/CHANGELOG.txt

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ v0.10.0 (WIP):
44
From this point ed::EndCreate() and ed::EndDelete() can only be called when
55
ed::BeginCreate() and ed::BeginDelete() calls were successful.
66

7+
RESTRUCTURE:
8+
Removed local copy of all dependencies in favor of auto checkout. This should also reduce
9+
user confusion and attempt to use ancient version of ImGui embedded in the repository.
10+
711
NEW: Canvas: Add example of zooming at fixed point (#270)
812

913
NEW: Editor: Add smooth zoom (#266)

examples/CMakeLists.txt

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.12)
22

3-
project(imgui-node-editor)
3+
project(imgui-node-editor-examples)
44

55
# Define IMGUI_NODE_EDITOR_ROOT_DIR pointing to project root directory
66
get_filename_component(IMGUI_NODE_EDITOR_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. ABSOLUTE CACHE)
@@ -9,16 +9,12 @@ get_filename_component(IMGUI_NODE_EDITOR_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. ABSOLUT
99
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1010

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

1414
# Node editor use C++14
1515
set(CMAKE_CXX_STANDARD 14)
1616
set(CMAKE_CXX_STANDARD_REQUIRED YES)
1717

18-
19-
20-
21-
2218
# Macro that will configure an example application
2319
macro(add_example_executable name)
2420
project(${name})
@@ -132,3 +128,5 @@ add_subdirectory(simple-example)
132128
add_subdirectory(widgets-example)
133129
add_subdirectory(basic-interaction-example)
134130
add_subdirectory(blueprints-example)
131+
132+
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT blueprints-example)

examples/application/CMakeLists.txt

+14-65
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ set(_Application_Sources
44
include/application.h
55
source/application.cpp
66
source/entry_point.cpp
7-
source/imgui_extra_keys.h
87
source/config.h.in
98
source/setup.h
109
source/platform.h
@@ -19,75 +18,25 @@ add_library(application STATIC)
1918

2019
target_include_directories(application PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
2120

22-
find_package(imgui REQUIRED)
23-
find_package(stb_image REQUIRED)
24-
find_package(ScopeGuard REQUIRED)
25-
target_link_libraries(application PUBLIC imgui)
26-
target_link_libraries(application PRIVATE stb_image ScopeGuard)
27-
21+
set(imgui_components)
2822
if (WIN32)
29-
list(APPEND _Application_Sources
30-
source/imgui_impl_dx11.cpp
31-
source/imgui_impl_dx11.h
32-
source/imgui_impl_win32.cpp
33-
source/imgui_impl_win32.h
34-
)
35-
36-
set(_DXSDK_Dir ${IMGUI_NODE_EDITOR_ROOT_DIR}/external/DXSDK)
37-
set(_DXSDK_Arch x86)
38-
if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
39-
set(_DXSDK_Arch x64)
40-
endif()
41-
42-
add_library(dxerr STATIC ${_DXSDK_Dir}/src/dxerr.cpp)
43-
target_include_directories(dxerr PUBLIC "${_DXSDK_Dir}/include")
44-
set_property(TARGET dxerr PROPERTY FOLDER "external")
45-
46-
add_library(d3dx11 UNKNOWN IMPORTED)
47-
set_target_properties(d3dx11 PROPERTIES
48-
IMPORTED_LOCATION "${_DXSDK_Dir}/lib/${_DXSDK_Arch}/d3dx11.lib"
49-
IMPORTED_LOCATION_DEBUG "${_DXSDK_Dir}/lib/${_DXSDK_Arch}/d3dx11d.lib"
50-
INTERFACE_INCLUDE_DIRECTORIES "${_DXSDK_Dir}/include"
51-
INTERFACE_LINK_LIBRARIES "$<$<CONFIG:Debug>:dxerr>"
52-
)
23+
list(APPEND imgui_components win32 dx11)
24+
target_link_libraries(application PRIVATE imgui::win32 imgui::dx11)
25+
#else()
26+
find_package(glfw REQUIRED)
27+
list(APPEND imgui_components glfw opengl3)
28+
target_link_libraries(application PRIVATE imgui::glfw imgui::opengl3)
29+
set(HAVE_GLFW3 YES)
30+
endif()
5331

54-
target_link_libraries(application PRIVATE d3d11.lib d3dcompiler.lib d3dx11)
55-
else()
56-
find_package(OpenGL REQUIRED)
57-
find_package(glfw3 3 REQUIRED)
5832

59-
if (APPLE)
60-
target_link_libraries(application PRIVATE
61-
"-framework CoreFoundation"
62-
"-framework Cocoa"
63-
"-framework IOKit"
64-
"-framework CoreVideo"
65-
)
66-
endif()
67-
endif()
33+
find_package(imgui REQUIRED COMPONENTS ${imgui_components})
34+
find_package(stb REQUIRED COMPONENTS image)
35+
target_link_libraries(application PUBLIC imgui)
36+
target_link_libraries(application PRIVATE stb::image)
6837

6938
if (OpenGL_FOUND)
7039
set(HAVE_OPENGL YES)
71-
72-
target_include_directories(application PRIVATE ${OPENGL_INCLUDE_DIR})
73-
target_link_libraries(application PRIVATE ${OPENGL_gl_LIBRARY})
74-
list(APPEND _Application_Sources
75-
source/imgui_impl_opengl3.cpp
76-
source/imgui_impl_opengl3.h
77-
source/imgui_impl_opengl3_loader.h
78-
)
79-
endif()
80-
81-
if (glfw3_FOUND)
82-
set(HAVE_GLFW3 YES)
83-
84-
list(APPEND _Application_Sources
85-
source/imgui_impl_glfw.cpp
86-
source/imgui_impl_glfw.h
87-
)
88-
target_link_libraries(application PRIVATE
89-
glfw
90-
)
9140
endif()
9241

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

10756
target_sources(application PRIVATE ${_Application_Sources})
10857

109-
set_property(TARGET application PROPERTY FOLDER "examples")
58+
set_property(TARGET application PROPERTY FOLDER "lib")

examples/application/source/application.cpp

+31-25
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
# include "setup.h"
33
# include "platform.h"
44
# include "renderer.h"
5-
6-
extern "C" {
7-
#define STB_IMAGE_IMPLEMENTATION
8-
#define STB_IMAGE_STATIC
9-
#include "stb_image.h"
10-
}
11-
5+
# include "stb_image.h"
126

137
Application::Application(const char* name)
148
: Application(name, 0, nullptr)
@@ -94,9 +88,8 @@ void Application::RecreateFontAtlas()
9488
io.Fonts = IM_NEW(ImFontAtlas);
9589

9690
ImFontConfig config;
97-
config.OversampleH = 4;
98-
config.OversampleV = 4;
99-
config.PixelSnapH = false;
91+
config.PixelSnapH = true;
92+
config.RasterizerDensity = m_Platform->GetFramebufferScale();
10093

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

114107
if (m_Platform->HasFramebufferScaleChanged())
115108
{
109+
m_Renderer->InvalidateResources();
116110
RecreateFontAtlas();
111+
m_Renderer->UpdateResources();
117112
m_Platform->AcknowledgeFramebufferScaleChanged();
118113
}
119114

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

123-
if (io.WantSetMousePos)
124-
{
125-
io.MousePos.x *= windowScale;
126-
io.MousePos.y *= windowScale;
127-
}
128-
129118
m_Platform->NewFrame();
130119

131-
// Don't touch "uninitialized" mouse position
132-
if (io.MousePos.x > -FLT_MAX && io.MousePos.y > -FLT_MAX)
133-
{
134-
io.MousePos.x /= windowScale;
135-
io.MousePos.y /= windowScale;
136-
}
137-
io.DisplaySize.x /= windowScale;
138-
io.DisplaySize.y /= windowScale;
120+
io.DisplaySize.x *= windowScale;
121+
io.DisplaySize.y *= windowScale;
139122

140123
io.DisplayFramebufferScale.x = framebufferScale;
141124
io.DisplayFramebufferScale.y = framebufferScale;
@@ -163,7 +146,30 @@ void Application::Frame()
163146
// Rendering
164147
m_Renderer->Clear(ImColor(32, 32, 32, 255));
165148
ImGui::Render();
166-
m_Renderer->RenderDrawData(ImGui::GetDrawData());
149+
150+
// Manually scale the draw data, because ImGui backends are not yet
151+
// consistent in handling FramebufferScale
152+
auto drawData = ImGui::GetDrawData();
153+
154+
drawData->DisplaySize.x /= windowScale;
155+
drawData->DisplaySize.y /= windowScale;
156+
157+
for (int i = 0; i < drawData->CmdListsCount; i++)
158+
{
159+
auto& cmdList = drawData->CmdLists[i];
160+
for (auto& vtx : cmdList->VtxBuffer)
161+
{
162+
vtx.pos.x *= framebufferScale;
163+
vtx.pos.y *= framebufferScale;
164+
}
165+
}
166+
167+
drawData->ScaleClipRects(drawData->FramebufferScale);
168+
169+
drawData->FramebufferScale.x = 1.0f;
170+
drawData->FramebufferScale.y = 1.0f;
171+
172+
m_Renderer->RenderDrawData(drawData);
167173

168174
m_Platform->FinishFrame();
169175
}

examples/application/source/imgui_extra_keys.h

-65
This file was deleted.

0 commit comments

Comments
 (0)