Build ImGui
This commit is contained in:
parent
386f52a85f
commit
2785e3f138
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -23,3 +23,7 @@
|
|||||||
[submodule "dependencies/runtime/src"]
|
[submodule "dependencies/runtime/src"]
|
||||||
path = dependencies/runtime/src
|
path = dependencies/runtime/src
|
||||||
url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/runtime.git
|
url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/runtime.git
|
||||||
|
[submodule "dependencies/imgui/src"]
|
||||||
|
path = dependencies/imgui/src
|
||||||
|
url = https://github.com/ocornut/imgui.git
|
||||||
|
ignore = dirty
|
||||||
|
8
dependencies/CMakeLists.txt
vendored
8
dependencies/CMakeLists.txt
vendored
@ -19,12 +19,16 @@ endif()
|
|||||||
# Extra Runtime
|
# Extra Runtime
|
||||||
add_subdirectory(runtime)
|
add_subdirectory(runtime)
|
||||||
# GLFW
|
# GLFW
|
||||||
if(BUILD_MEDIA_LAYER_CORE)
|
if(BUILD_NATIVE_COMPONENTS OR BUILD_MEDIA_LAYER_CORE)
|
||||||
add_subdirectory(glfw)
|
add_subdirectory(glfw)
|
||||||
endif()
|
endif()
|
||||||
|
# ImGui
|
||||||
|
if(BUILD_NATIVE_COMPONENTS)
|
||||||
|
add_subdirectory(imgui)
|
||||||
|
endif()
|
||||||
# UTF8-CPP
|
# UTF8-CPP
|
||||||
add_subdirectory(utf8cpp)
|
add_subdirectory(utf8cpp)
|
||||||
# Symbol Prcoessor
|
# Symbol Processor
|
||||||
if(BUILD_ARM_COMPONENTS)
|
if(BUILD_ARM_COMPONENTS)
|
||||||
add_subdirectory(symbol-processor)
|
add_subdirectory(symbol-processor)
|
||||||
endif()
|
endif()
|
||||||
|
2
dependencies/glfw/CMakeLists.txt
vendored
2
dependencies/glfw/CMakeLists.txt
vendored
@ -24,4 +24,4 @@ unset(MESSAGE_QUIET)
|
|||||||
setup_library(glfw TRUE FALSE)
|
setup_library(glfw TRUE FALSE)
|
||||||
|
|
||||||
# License
|
# License
|
||||||
install(FILES src/LICENSE.md DESTINATION "${MCPI_LEGAL_DIR}/glfw")
|
install(FILES src/LICENSE.md DESTINATION "${MCPI_LEGAL_DIR}/GLFW")
|
||||||
|
41
dependencies/imgui/CMakeLists.txt
vendored
Normal file
41
dependencies/imgui/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
project(imgui)
|
||||||
|
|
||||||
|
# Silence Warnings
|
||||||
|
add_compile_options(-w)
|
||||||
|
|
||||||
|
## ImGui
|
||||||
|
|
||||||
|
# Build
|
||||||
|
add_library(imgui SHARED
|
||||||
|
src/imgui.cpp
|
||||||
|
src/imgui_draw.cpp
|
||||||
|
src/imgui_tables.cpp
|
||||||
|
src/imgui_widgets.cpp
|
||||||
|
src/backends/imgui_impl_glfw.cpp
|
||||||
|
src/backends/imgui_impl_opengl2.cpp
|
||||||
|
)
|
||||||
|
setup_header_dirs(imgui
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/src"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/src/backends"
|
||||||
|
)
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
target_link_libraries(imgui PUBLIC glfw OpenGL::GL)
|
||||||
|
|
||||||
|
# Patch
|
||||||
|
function(run_patch)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "patch" "-p1" "--quiet" ${ARGN}
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src"
|
||||||
|
INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/fix-hidpi.patch"
|
||||||
|
COMMAND_ERROR_IS_FATAL ANY
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
# https://stackoverflow.com/a/79041978
|
||||||
|
run_patch("--batch" "--reverse")
|
||||||
|
run_patch()
|
||||||
|
|
||||||
|
# Install
|
||||||
|
setup_library(imgui TRUE TRUE)
|
||||||
|
|
||||||
|
# License
|
||||||
|
install(FILES src/LICENSE.txt DESTINATION "${MCPI_LEGAL_DIR}/ImGui")
|
55
dependencies/imgui/fix-hidpi.patch
vendored
Normal file
55
dependencies/imgui/fix-hidpi.patch
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
--- a/backends/imgui_impl_glfw.cpp
|
||||||
|
+++ b/backends/imgui_impl_glfw.cpp
|
||||||
|
@@ -422,6 +422,21 @@ void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused)
|
||||||
|
io.AddFocusEvent(focused != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void ImGui_ImplGlfw_ScaleMousePos(GLFWwindow* window, double &x, double &y) {
|
||||||
|
+ // Get Window Size
|
||||||
|
+ int window_width, window_height;
|
||||||
|
+ glfwGetWindowSize(window, &window_width, &window_height);
|
||||||
|
+ if (window_width <= 0 || window_height <= 0) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Get Framebuffer Size
|
||||||
|
+ int framebuffer_width, framebuffer_height;
|
||||||
|
+ glfwGetFramebufferSize(window, &framebuffer_width, &framebuffer_height);
|
||||||
|
+ // Multiply
|
||||||
|
+ x *= double(framebuffer_width) / double(window_width);
|
||||||
|
+ y *= double(framebuffer_height) / double(window_height);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
@@ -429,6 +444,7 @@ void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y)
|
||||||
|
bd->PrevUserCallbackCursorPos(window, x, y);
|
||||||
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
+ ImGui_ImplGlfw_ScaleMousePos(window, x, y);
|
||||||
|
io.AddMousePosEvent((float)x, (float)y);
|
||||||
|
bd->LastValidMousePos = ImVec2((float)x, (float)y);
|
||||||
|
}
|
||||||
|
@@ -738,6 +754,7 @@ static void ImGui_ImplGlfw_UpdateMouseData()
|
||||||
|
{
|
||||||
|
double mouse_x, mouse_y;
|
||||||
|
glfwGetCursorPos(window, &mouse_x, &mouse_y);
|
||||||
|
+ ImGui_ImplGlfw_ScaleMousePos(window, mouse_x, mouse_y);
|
||||||
|
bd->LastValidMousePos = ImVec2((float)mouse_x, (float)mouse_y);
|
||||||
|
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
|
||||||
|
}
|
||||||
|
@@ -831,13 +848,9 @@ void ImGui_ImplGlfw_NewFrame()
|
||||||
|
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplGlfw_InitForXXX()?");
|
||||||
|
|
||||||
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
|
- int w, h;
|
||||||
|
int display_w, display_h;
|
||||||
|
- glfwGetWindowSize(bd->Window, &w, &h);
|
||||||
|
glfwGetFramebufferSize(bd->Window, &display_w, &display_h);
|
||||||
|
- io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
|
- if (w > 0 && h > 0)
|
||||||
|
- io.DisplayFramebufferScale = ImVec2((float)display_w / (float)w, (float)display_h / (float)h);
|
||||||
|
+ io.DisplaySize = ImVec2((float)display_w, (float)display_h);
|
||||||
|
|
||||||
|
// Setup time step
|
||||||
|
// (Accept glfwGetTime() not returning a monotonically increasing value. Seems to happens on disconnecting peripherals and probably on VMs and Emscripten, see #6491, #6189, #6114, #3644)
|
1
dependencies/imgui/src
vendored
Submodule
1
dependencies/imgui/src
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit eb0ad66d88d96be3ccad31e22ef9d3126ec79ef2
|
6
dependencies/runtime/CMakeLists.txt
vendored
6
dependencies/runtime/CMakeLists.txt
vendored
@ -11,3 +11,9 @@ endif()
|
|||||||
|
|
||||||
# Build
|
# Build
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
# RPath
|
||||||
|
if(TARGET runtime)
|
||||||
|
set_target_properties(runtime PROPERTIES INSTALL_RPATH "$ORIGIN/../lib/native")
|
||||||
|
target_link_options(runtime PRIVATE "LINKER:--disable-new-dtags")
|
||||||
|
endif()
|
2
dependencies/runtime/src
vendored
2
dependencies/runtime/src
vendored
@ -1 +1 @@
|
|||||||
Subproject commit b42021ba5d45c29e22cbdd887e2fae5a1c1334a1
|
Subproject commit 043d926f32a3315d92bce1d9bbb0ccdcf99c11a2
|
2
dependencies/utf8cpp/CMakeLists.txt
vendored
2
dependencies/utf8cpp/CMakeLists.txt
vendored
@ -9,4 +9,4 @@ add_compile_options(-w)
|
|||||||
add_subdirectory(src EXCLUDE_FROM_ALL)
|
add_subdirectory(src EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
# License
|
# License
|
||||||
install(FILES src/LICENSE DESTINATION "${MCPI_LEGAL_DIR}/utf8cpp")
|
install(FILES src/LICENSE DESTINATION "${MCPI_LEGAL_DIR}/UTF8-CPP")
|
||||||
|
Loading…
Reference in New Issue
Block a user