Skip to content

Commit 41c98d4

Browse files
authored
Merge pull request #28912 from jeongseok-meta/vsgImGui
2 parents 610205b + f50388e commit 41c98d4

File tree

9 files changed

+701
-0
lines changed

9 files changed

+701
-0
lines changed

recipes/vsgimgui/bld.bat

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@echo on
2+
3+
:: Remove existing imgui and implot headers to use the external ones installed by their Conda packages
4+
del /q include\vsgImGui\imgui.h
5+
del /q include\vsgImGui\implot.h
6+
if errorlevel 1 exit 1
7+
8+
cmake %SRC_DIR% ^
9+
%CMAKE_ARGS% ^
10+
-B build ^
11+
-DBUILD_SHARED_LIBS=ON ^
12+
-DVSG_IMGUI_USE_SYSTEM_IMGUI=ON ^
13+
-DVSG_IMGUI_USE_SYSTEM_IMPLOT=ON
14+
if errorlevel 1 exit 1
15+
16+
cmake --build build --parallel --config Release
17+
if errorlevel 1 exit 1
18+
19+
cmake --install build --config Release
20+
if errorlevel 1 exit 1

recipes/vsgimgui/build.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -exo pipefail
4+
5+
# Remove existing imgui and implot headers to use the external ones installed by their Conda packages
6+
rm include/vsgImGui/imgui.h
7+
rm include/vsgImGui/implot.h
8+
9+
cmake $SRC_DIR \
10+
${CMAKE_ARGS} \
11+
-G Ninja \
12+
-B build \
13+
-DBUILD_SHARED_LIBS=ON \
14+
-DCMAKE_BUILD_TYPE=Release \
15+
-DVSG_IMGUI_USE_SYSTEM_IMGUI=ON \
16+
-DVSG_IMGUI_USE_SYSTEM_IMPLOT=ON
17+
18+
cmake --build build --parallel
19+
20+
cmake --install build --strip

recipes/vsgimgui/meta.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{% set name = "vsgImGui" %}
2+
{% set version = "0.6.0" %}
3+
4+
package:
5+
name: {{ name|lower }}
6+
version: {{ version }}
7+
8+
source:
9+
- url: https://github.com/vsg-dev/vsgImGui/archive/v{{ version }}.tar.gz
10+
sha256: 1697d53c4d4a91b90837c16196d891ecff20bb0469e1947caccada03e6dca864
11+
patches:
12+
- patches/0001-Add-options-to-use-system-dependencies.patch
13+
- patches/0003-Find-imgui-and-implot-in-package-config-when-system-.patch
14+
15+
build:
16+
number: 0
17+
run_exports:
18+
- {{ pin_subpackage('vsgimgui', max_pin='x.x') }}
19+
20+
requirements:
21+
build:
22+
- {{ compiler('cxx') }}
23+
- {{ stdlib('c') }}
24+
- cmake
25+
- ninja # [not win]
26+
- pkgconfig # [linux]
27+
host:
28+
- imgui
29+
- implot
30+
- libvulkan-headers
31+
- libvulkan-loader
32+
- vulkanscenegraph
33+
run:
34+
- libvulkan-loader
35+
- vulkanscenegraph
36+
37+
test:
38+
commands:
39+
- test -f $PREFIX/include/vsgImGui/Export.h # [not win]
40+
- test -f $PREFIX/lib/libvsgImGui${SHLIB_EXT} # [not win]
41+
- test -f $PREFIX/lib/cmake/vsgImGui/vsgImGuiConfig.cmake # [not win]
42+
- if not exist %PREFIX%\\Library\\include\\vsgImGui\\Export.h exit 1 # [win]
43+
- if not exist %PREFIX%\\Library\\lib\\vsgImGui.lib exit 1 # [win]
44+
- if not exist %PREFIX%\\Library\\bin\\vsgImGui.dll exit 1 # [win]
45+
- if not exist %PREFIX%\\Library\\lib\\cmake\\vsgImGui\\vsgImGuiConfig.cmake exit 1 # [win]
46+
requires:
47+
- {{ compiler("c") }}
48+
- {{ compiler("cxx") }}
49+
- cmake
50+
- ninja # [not win]
51+
- pkgconfig # [linux]
52+
- vsgXchange
53+
files:
54+
- tests/
55+
56+
about:
57+
home: https://vsg-dev.github.io/vsg-dev.io/
58+
summary: Integration of VulkanSceneGraph with ImGui
59+
license: MIT
60+
license_file: LICENSE.md
61+
dev_url: https://github.com/vsg-dev/vsgImGui
62+
63+
extra:
64+
recipe-maintainers:
65+
- jeongseok-meta
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
From 13d974246cea7cb24b985008516a947bf393f53c Mon Sep 17 00:00:00 2001
2+
From: Jeongseok Lee <jeongseok@meta.com>
3+
Date: Thu, 23 Jan 2025 15:36:00 -0800
4+
Subject: [PATCH 1/2] Add options to use system dependencies
5+
6+
---
7+
CMakeLists.txt | 54 ++++++++++++++--------
8+
include/vsgImGui/RenderImGui.h | 2 +-
9+
src/CMakeLists.txt | 74 +++++++++++++++++++++---------
10+
src/vsgImGui/RenderImGui.cpp | 4 +-
11+
src/vsgImGui/SendEventsToImGui.cpp | 2 +-
12+
5 files changed, 93 insertions(+), 43 deletions(-)
13+
14+
diff --git a/CMakeLists.txt b/CMakeLists.txt
15+
index e1679d2..464b8ee 100644
16+
--- a/CMakeLists.txt
17+
+++ b/CMakeLists.txt
18+
@@ -5,6 +5,10 @@ project(vsgImGui
19+
DESCRIPTION "VulkanSceneGraph, ImGui and ImPlot integration library"
20+
LANGUAGES CXX
21+
)
22+
+
23+
+option(VSG_IMGUI_USE_SYSTEM_IMGUI "Use system installed ImGui" OFF)
24+
+option(VSG_IMGUI_USE_SYSTEM_IMPLOT "Use system installed ImPlot" OFF)
25+
+
26+
set(VSGIMGUI_SOVERSION 0)
27+
SET(VSGIMGUI_RELEASE_CANDIDATE 0)
28+
29+
@@ -27,29 +31,43 @@ find_package(vsg 1.0.5)
30+
vsg_setup_dir_vars()
31+
vsg_setup_build_vars()
32+
33+
-if ( (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/imgui/imgui.h) OR
34+
- (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/implot/implot.h) )
35+
- find_package(Git QUIET)
36+
+if(NOT VSG_IMGUI_USE_SYSTEM_IMGUI OR NOT VSG_IMGUI_USE_SYSTEM_IMPLOT)
37+
+ if ( (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/imgui/imgui.h) OR
38+
+ (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/implot/implot.h) )
39+
+ find_package(Git QUIET)
40+
41+
- execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
42+
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
43+
- RESULT_VARIABLE GIT_SUBMOD_RESULT)
44+
+ execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
45+
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
46+
+ RESULT_VARIABLE GIT_SUBMOD_RESULT)
47+
48+
- if(NOT GIT_SUBMOD_RESULT EQUAL "0")
49+
- message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
50+
+ if(NOT GIT_SUBMOD_RESULT EQUAL "0")
51+
+ message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
52+
+ endif()
53+
endif()
54+
endif()
55+
56+
-vsg_copy_imgui_headers(
57+
- FILES
58+
- ${VSGIMGUI_SOURCE_DIR}/src/imgui/imgui.h
59+
- ${VSGIMGUI_SOURCE_DIR}/src/imgui/imconfig.h
60+
- ${VSGIMGUI_SOURCE_DIR}/src/imgui/imgui_internal.h
61+
- ${VSGIMGUI_SOURCE_DIR}/src/imgui/imstb_textedit.h
62+
- ${VSGIMGUI_SOURCE_DIR}/src/imgui//misc/cpp/imgui_stdlib.h
63+
- ${VSGIMGUI_SOURCE_DIR}/src/implot/implot.h
64+
- ${VSGIMGUI_SOURCE_DIR}/src/implot/implot_internal.h
65+
-)
66+
+if(VSG_IMGUI_USE_SYSTEM_IMGUI)
67+
+ find_package(imgui CONFIG REQUIRED)
68+
+else()
69+
+ vsg_copy_imgui_headers(
70+
+ FILES
71+
+ ${VSGIMGUI_SOURCE_DIR}/src/imgui/imgui.h
72+
+ ${VSGIMGUI_SOURCE_DIR}/src/imgui/imconfig.h
73+
+ ${VSGIMGUI_SOURCE_DIR}/src/imgui/imgui_internal.h
74+
+ ${VSGIMGUI_SOURCE_DIR}/src/imgui/imstb_textedit.h
75+
+ ${VSGIMGUI_SOURCE_DIR}/src/imgui//misc/cpp/imgui_stdlib.h
76+
+ )
77+
+endif()
78+
+
79+
+if(VSG_IMGUI_USE_SYSTEM_IMPLOT)
80+
+ find_package(implot CONFIG REQUIRED)
81+
+else()
82+
+ vsg_copy_imgui_headers(
83+
+ FILES
84+
+ ${VSGIMGUI_SOURCE_DIR}/src/implot/implot.h
85+
+ ${VSGIMGUI_SOURCE_DIR}/src/implot/implot_internal.h
86+
+ )
87+
+endif()
88+
89+
vsg_add_target_clang_format(
90+
FILES
91+
diff --git a/include/vsgImGui/RenderImGui.h b/include/vsgImGui/RenderImGui.h
92+
index 26a644d..3e427cd 100644
93+
--- a/include/vsgImGui/RenderImGui.h
94+
+++ b/include/vsgImGui/RenderImGui.h
95+
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
96+
#include <vsg/vk/DescriptorPool.h>
97+
98+
#include <vsgImGui/Export.h>
99+
-#include <vsgImGui/imgui.h>
100+
+#include <imgui.h>
101+
102+
namespace vsgImGui
103+
{
104+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
105+
index 41d749d..97720b2 100644
106+
--- a/src/CMakeLists.txt
107+
+++ b/src/CMakeLists.txt
108+
@@ -6,41 +6,60 @@ set(EXTRA_INCLUDES)
109+
SET(HEADER_PATH ${VSGIMGUI_SOURCE_DIR}/include/vsgImGui)
110+
111+
set(HEADERS
112+
- ${HEADER_PATH}/imgui.h
113+
${HEADER_PATH}/SendEventsToImGui.h
114+
${HEADER_PATH}/RenderImGui.h
115+
${HEADER_PATH}/Texture.h
116+
- imgui/imconfig.h
117+
- imgui/imgui_internal.h
118+
- imgui/imstb_rectpack.h
119+
- imgui/imstb_textedit.h
120+
- imgui/imstb_truetype.h
121+
- imgui/misc/cpp/imgui_stdlib.h
122+
- implot/implot.h
123+
- implot/implot_internal.h
124+
)
125+
126+
set(SOURCES
127+
vsgImGui/RenderImGui.cpp
128+
vsgImGui/SendEventsToImGui.cpp
129+
vsgImGui/Texture.cpp
130+
- imgui/imgui.cpp
131+
- imgui/imgui_draw.cpp
132+
- imgui/imgui_tables.cpp
133+
- imgui/imgui_widgets.cpp
134+
- imgui/backends/imgui_impl_vulkan.cpp
135+
- imgui/misc/cpp/imgui_stdlib.cpp
136+
- implot/implot.cpp
137+
- implot/implot_items.cpp
138+
)
139+
140+
-OPTION(SHOW_DEMO_WINDOW "Toggle the build of the ImGui::ShowDemoWindow(bool*) and ImPlot::ShadowDemoWindow(bool*)" ON)
141+
+if(NOT VSG_IMGUI_USE_SYSTEM_IMGUI)
142+
+ set(HEADERS ${HEADERS}
143+
+ imgui/imgui.h
144+
+ imgui/imconfig.h
145+
+ imgui/imgui_internal.h
146+
+ imgui/imstb_rectpack.h
147+
+ imgui/imstb_textedit.h
148+
+ imgui/imstb_truetype.h
149+
+ imgui/misc/cpp/imgui_stdlib.h
150+
+ )
151+
152+
-if (SHOW_DEMO_WINDOW)
153+
set(SOURCES ${SOURCES}
154+
- imgui/imgui_demo.cpp
155+
- implot/implot_demo.cpp
156+
+ imgui/imgui.cpp
157+
+ imgui/imgui_draw.cpp
158+
+ imgui/imgui_tables.cpp
159+
+ imgui/imgui_widgets.cpp
160+
+ imgui/backends/imgui_impl_vulkan.cpp
161+
+ imgui/misc/cpp/imgui_stdlib.cpp
162+
+ )
163+
+endif()
164+
+
165+
+if(NOT VSG_IMGUI_USE_SYSTEM_IMPLOT)
166+
+ set(HEADERS ${HEADERS}
167+
+ implot/implot.h
168+
+ implot/implot_internal.h
169+
)
170+
+
171+
+ set(SOURCES ${SOURCES}
172+
+ implot/implot.cpp
173+
+ implot/implot_items.cpp
174+
+ )
175+
+endif()
176+
+
177+
+OPTION(SHOW_DEMO_WINDOW "Toggle the build of the ImGui::ShowDemoWindow(bool*) and ImPlot::ShadowDemoWindow(bool*)" ON)
178+
+
179+
+if (SHOW_DEMO_WINDOW)
180+
+ if(NOT VSG_IMGUI_USE_SYSTEM_IMGUI)
181+
+ set(HEADERS ${HEADERS} imgui/imgui_demo.cpp)
182+
+ endif()
183+
+
184+
+ if(NOT VSG_IMGUI_USE_SYSTEM_IMPLOT)
185+
+ set(SOURCES ${SOURCES} implot/implot_demo.cpp)
186+
+ endif()
187+
else()
188+
set(SOURCES ${SOURCES}
189+
vsgImGui/fallback_demo.cpp
190+
@@ -69,6 +88,11 @@ target_include_directories(vsgImGui PUBLIC
191+
$<INSTALL_INTERFACE:include>
192+
${EXTRA_INCLUDES}
193+
)
194+
+if(NOT VSG_IMGUI_USE_SYSTEM_IMGUI)
195+
+ target_include_directories(vsgImGui PRIVATE
196+
+ $<BUILD_INTERFACE:${VSGIMGUI_SOURCE_DIR}/src/imgui/backends>
197+
+ )
198+
+endif()
199+
200+
target_link_libraries(vsgImGui
201+
PUBLIC
202+
@@ -77,6 +101,14 @@ target_link_libraries(vsgImGui
203+
${EXTRA_LIBRARIES}
204+
)
205+
206+
+if(VSG_IMGUI_USE_SYSTEM_IMGUI)
207+
+ target_link_libraries(vsgImGui PUBLIC imgui::imgui)
208+
+endif()
209+
+
210+
+if(VSG_IMGUI_USE_SYSTEM_IMPLOT)
211+
+ target_link_libraries(vsgImGui PUBLIC implot::implot)
212+
+endif()
213+
+
214+
install(TARGETS vsgImGui ${INSTALL_TARGETS_DEFAULT_FLAGS})
215+
216+
if (BUILD_SHARED_LIBS)
217+
diff --git a/src/vsgImGui/RenderImGui.cpp b/src/vsgImGui/RenderImGui.cpp
218+
index 306030b..f0af046 100644
219+
--- a/src/vsgImGui/RenderImGui.cpp
220+
+++ b/src/vsgImGui/RenderImGui.cpp
221+
@@ -22,9 +22,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
222+
</editor-fold> */
223+
224+
#include <vsgImGui/RenderImGui.h>
225+
-#include <vsgImGui/implot.h>
226+
+#include <implot.h>
227+
228+
-#include "../imgui/backends/imgui_impl_vulkan.h"
229+
+#include <imgui_impl_vulkan.h>
230+
231+
#include <vsg/io/Logger.h>
232+
#include <vsg/vk/State.h>
233+
diff --git a/src/vsgImGui/SendEventsToImGui.cpp b/src/vsgImGui/SendEventsToImGui.cpp
234+
index 11de226..ef784fc 100644
235+
--- a/src/vsgImGui/SendEventsToImGui.cpp
236+
+++ b/src/vsgImGui/SendEventsToImGui.cpp
237+
@@ -22,7 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
238+
</editor-fold> */
239+
240+
#include <vsgImGui/SendEventsToImGui.h>
241+
-#include <vsgImGui/imgui.h>
242+
+#include <imgui.h>
243+
244+
#include <vsg/ui/KeyEvent.h>
245+
#include <vsg/ui/PointerEvent.h>
246+
--
247+
2.20.1.windows.1
248+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
From 371693daf6845b7051fcbbd99f45533100e17864 Mon Sep 17 00:00:00 2001
2+
From: Jeongseok Lee <jeongseok@meta.com>
3+
Date: Thu, 23 Jan 2025 17:01:25 -0800
4+
Subject: [PATCH 3/3] Find imgui and implot in package config when system
5+
installed ones were used
6+
7+
---
8+
src/vsgImGuiConfig.cmake.in | 7 +++++++
9+
1 file changed, 7 insertions(+)
10+
11+
diff --git a/src/vsgImGuiConfig.cmake.in b/src/vsgImGuiConfig.cmake.in
12+
index e2c14f2..80f9b41 100644
13+
--- a/src/vsgImGuiConfig.cmake.in
14+
+++ b/src/vsgImGuiConfig.cmake.in
15+
@@ -2,5 +2,12 @@ include(CMakeFindDependencyMacro)
16+
17+
find_dependency(Vulkan)
18+
find_dependency(vsg)
19+
+if(@VSG_IMGUI_USE_SYSTEM_IMGUI@)
20+
+ find_dependency(imgui CONFIG)
21+
+endif()
22+
+
23+
+if(@VSG_IMGUI_USE_SYSTEM_IMPLOT@)
24+
+ find_dependency(implot CONFIG)
25+
+endif()
26+
27+
include("${CMAKE_CURRENT_LIST_DIR}/vsgImGuiTargets.cmake")
28+
--
29+
2.20.1.windows.1
30+

recipes/vsgimgui/run_test.bat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@echo on
2+
3+
cmake tests ^
4+
%CMAKE_ARGS% ^
5+
-B tests/build ^
6+
-DBUILD_SHARED_LIBS=ON
7+
if errorlevel 1 exit 1
8+
9+
cmake --build tests/build --parallel --config Release
10+
if errorlevel 1 exit 1

0 commit comments

Comments
 (0)