Skip to content

Commit 1da43a2

Browse files
authored
Update ImGui to 1.92.5, rework font handling for dynamic fonts (#379)
* update imgui to v1.92.5 * update for imgui version, rework font handling for dynamic fonts * propagate context changes to screenshot * use null backend for mock, fix imgui backend cmake * use null platform backend for EGL * unrelated: parallel builds everywhere * add additional checkinitialized() * explicitly free resources during engine shutdown * give a nicer error for bad backend name * multi-context seems to work cross platform and without leaks * missing include * fix for "" auto backends * change multi-backend workaround for latest imgui updates * add icon font * tweak double click selection behavior * use consistent initialization check * mitigate the broken-ness of screenshots with UI
1 parent 81ddb1c commit 1da43a2

30 files changed

+9986
-205
lines changed

deps/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ endif()
4141
if(NOT TARGET stb)
4242
add_subdirectory(stb)
4343
endif()
44+
45+
## IconFontCppHeaders
46+
if(NOT TARGET IconFontCppHeaders)
47+
add_subdirectory(IconFontCppHeaders)
48+
endif()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_library(IconFontCppHeaders INTERFACE)
2+
3+
target_include_directories(IconFontCppHeaders INTERFACE "include")

deps/IconFontCppHeaders/README.md

Lines changed: 246 additions & 0 deletions
Large diffs are not rendered by default.

deps/IconFontCppHeaders/include/IconFontCppHeaders/IconsLucide.h

Lines changed: 1661 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Copyright (c) 2017 Juliette Foucaut and Doug Binks
2+
3+
This software is provided 'as-is', without any express or implied
4+
warranty. In no event will the authors be held liable for any damages
5+
arising from the use of this software.
6+
7+
Permission is granted to anyone to use this software for any purpose,
8+
including commercial applications, and to alter it and redistribute it
9+
freely, subject to the following restrictions:
10+
11+
1. The origin of this software must not be misrepresented; you must not
12+
claim that you wrote the original software. If you use this software
13+
in a product, an acknowledgment in the product documentation would be
14+
appreciated but is not required.
15+
2. Altered source versions must be plainly marked as such, and must not be
16+
misrepresented as being the original software.
17+
3. This notice may not be removed or altered from any source distribution.

deps/imgui/CMakeLists.txt

Lines changed: 62 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,63 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STR
1515
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-everything")
1616
endif()
1717
endif()
18-
19-
18+
19+
# imgui sources
20+
list(APPEND SRCS
21+
imgui/imgui.cpp
22+
imgui/imgui_draw.cpp
23+
imgui/imgui_tables.cpp
24+
imgui/imgui_widgets.cpp
25+
imgui/imgui_demo.cpp
26+
)
27+
28+
# implot sources
29+
list(APPEND SRCS
30+
implot/implot.cpp
31+
implot/implot_items.cpp
32+
)
33+
34+
# imguizmo sources
35+
list(APPEND SRCS
36+
ImGuizmo/ImGuizmo.cpp
37+
)
38+
39+
40+
# Add per-backend sources
2041
if("${POLYSCOPE_BACKEND_OPENGL3_GLFW}")
2142

22-
# imgui sources
2343
list(APPEND SRCS
24-
imgui/imgui.cpp
25-
imgui/imgui_draw.cpp
26-
imgui/imgui_tables.cpp
27-
imgui/imgui_widgets.cpp
28-
imgui/imgui_demo.cpp
29-
imgui/backends/imgui_impl_glfw.cpp
30-
imgui/backends/imgui_impl_opengl3.cpp
31-
)
44+
imgui/backends/imgui_impl_opengl3.cpp
45+
imgui/backends/imgui_impl_glfw.cpp
46+
)
47+
endif()
48+
if("${POLYSCOPE_BACKEND_OPENGL3_EGL}")
49+
# this backend supports linux only
3250

33-
# implot sources
3451
list(APPEND SRCS
35-
implot/implot.cpp
36-
implot/implot_items.cpp
52+
imgui/backends/imgui_impl_opengl3.cpp
3753
)
38-
39-
# imguizmosources
54+
endif()
55+
if("${POLYSCOPE_BACKEND_OPENGL_MOCK}")
56+
4057
list(APPEND SRCS
41-
ImGuizmo/ImGuizmo.cpp
58+
imgui/backends/imgui_impl_null.cpp
4259
)
60+
endif()
61+
4362

44-
add_library(
45-
imgui
46-
${SRCS}
47-
)
63+
add_library(imgui ${SRCS})
64+
target_compile_features(imgui PUBLIC cxx_std_11)
65+
set_target_properties(imgui PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
66+
67+
# Per-backend settings
68+
if("${POLYSCOPE_BACKEND_OPENGL3_GLFW}")
4869

4970
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui/")
71+
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/custom_backends/")
5072
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/implot/")
5173
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/ImGuizmo/")
5274
target_include_directories(imgui PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../glad/include/")
53-
5475
target_link_libraries(imgui PRIVATE glfw)
5576

5677
if(APPLE)
@@ -71,27 +92,30 @@ if("${POLYSCOPE_BACKEND_OPENGL3_GLFW}")
7192
add_definitions(-DIMGUI_IMPL_OPENGL_LOADER_GLAD)
7293
target_link_libraries(imgui PRIVATE glad)
7394
endif()
95+
endif()
7496

75-
elseif("${POLYSCOPE_BACKEND_OPENGL_MOCK}")
76-
77-
# Disable every platform-specific thing I can find in imgui
78-
add_definitions(-DIMGUI_DISABLE_OSX_FUNCTIONS)
79-
add_definitions(-DIMGUI_DISABLE_WIN32_FUNCTIONS)
80-
add_definitions(-DIMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
81-
add_definitions(-DIMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
82-
83-
set(SRCS imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_tables.cpp imgui/imgui_widgets.cpp imgui/imgui_demo.cpp)
84-
85-
add_library(
86-
imgui
87-
${SRCS}
88-
)
97+
if("${POLYSCOPE_BACKEND_OPENGL3_EGL}")
98+
# this backend supports linux only
8999

90100
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui/")
101+
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/implot/")
102+
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/ImGuizmo/")
103+
target_include_directories(imgui PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../glad/include/")
91104

105+
# linux only
106+
add_definitions(-DIMGUI_IMPL_OPENGL_LOADER_GLAD)
107+
target_link_libraries(imgui PRIVATE glad)
92108
endif()
93109

110+
if("${POLYSCOPE_BACKEND_OPENGL_MOCK}")
94111

95-
target_compile_features(imgui PUBLIC cxx_std_11)
112+
# Disable every platform-specific thing I can find in imgui
113+
# add_definitions(-DIMGUI_DISABLE_OSX_FUNCTIONS)
114+
# add_definitions(-DIMGUI_DISABLE_WIN32_FUNCTIONS)
115+
# add_definitions(-DIMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
116+
# add_definitions(-DIMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
96117

97-
set_target_properties(imgui PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
118+
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui/")
119+
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/custom_backends/")
120+
121+
endif()

deps/imgui/imgui

Submodule imgui updated 144 files

include/polyscope/imgui_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ namespace polyscope {
1111

1212
// Default implementations of callbacks to set ImGui style / fonts
1313
void configureImGuiStyle();
14-
std::tuple<ImFontAtlas*, ImFont*, ImFont*> prepareImGuiFonts();
14+
std::tuple<ImFont*, ImFont*> loadBaseFonts(ImFontAtlas* fontAtlas);
1515

1616
} // namespace polyscope

include/polyscope/internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ namespace internal {
2323
// Get a unique identifier
2424
uint64_t getNextUniqueID();
2525

26+
// How many layers deep in the polyscope context stack are we
27+
extern int contextStackSize;
28+
2629
// track various fire-once warnings
2730
extern bool& pointCloudEfficiencyWarningReported;
2831

include/polyscope/options.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ extern bool doDefaultMouseInteraction;
142142
// may assign your own function to create custom styles. If this callback is null, the default ImGui style will be used.
143143
extern std::function<void()> configureImGuiStyleCallback;
144144

145-
// A callback function which will be invoked exactly once during initialization to construct a font atlas for ImGui to
146-
// use. The callback should return a tuple of three pointers: a newly created global shared font atlas, a regular font,
147-
// and a mono font. By default, this is set to invoke prepareImGuiFonts() from Polyscope's imgui_config.cpp, but you may
148-
// assign your own function to create custom styles. If this callback is null, default fonts will be used.
149-
extern std::function<std::tuple<ImFontAtlas*, ImFont*, ImFont*>()> prepareImGuiFontsCallback;
145+
// A callback function which will be invoked exactly once during initialization to add fonts to a font atlas for ImGui
146+
// to use. The callback should return two pointers: a regular font and a mono font. By default, this is set to invoke
147+
// loadBaseFonts() from Polyscope's imgui_config.cpp, but you may assign your own function to create custom styles. If
148+
// this callback is null, default fonts will be used.
149+
extern std::function<std::tuple<ImFont*, ImFont*>(ImFontAtlas*)> prepareImGuiFontsCallback;
150150

151151
// === Backend and low-level options
152152

0 commit comments

Comments
 (0)