From 84caba707abf1e11d8b72388d52720a7d55bc814 Mon Sep 17 00:00:00 2001 From: FlightlessMango Date: Thu, 21 Sep 2023 22:05:21 +0200 Subject: [PATCH] subproject: implot --- .gitignore | 1 + meson.build | 12 ++++++++++++ src/app/main.cpp | 6 ++++++ src/gl/gl_hud.cpp | 6 ++++++ src/meson.build | 11 +++++++++-- src/vulkan.cpp | 6 ++++++ subprojects/implot.wrap | 13 +++++++++++++ 7 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 subprojects/implot.wrap diff --git a/.gitignore b/.gitignore index 206fc293..8e63a955 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ subprojects/Vulkan-Headers-*/ subprojects/imgui-*/ subprojects/spdlog-*/ subprojects/nlohmann_json-*/ +subprojects/implot-*/ #GNU Global Metadata **/GPATH diff --git a/meson.build b/meson.build index e6ba11ba..6d20f4a5 100644 --- a/meson.build +++ b/meson.build @@ -215,6 +215,18 @@ endif dearimgui_sp = subproject('imgui', default_options: imgui_options) dearimgui_dep = dearimgui_sp.get_variable('imgui_dep') +if is_unixy +implot_sp = subproject('implot') +implot_dep = implot_sp.get_variable('implot_dep') +implot_lib = static_library( + 'implot_static', + objects: implot_sp.get_variable('implot_lib').extract_all_objects() +) +else +implot_dep = null_dep +implot_lib = static_library('nulllib', []) +endif + spdlog_dep = cpp.find_library('spdlog', required: get_option('use_system_spdlog')) if not spdlog_dep.found() spdlog_sp = subproject('spdlog', default_options: [ diff --git a/src/app/main.cpp b/src/app/main.cpp index a5cf4017..c8790c2d 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -19,6 +19,9 @@ #include #include #include "amdgpu.h" +#ifdef __linux__ +#include "implot.h" +#endif #define GLFW_EXPOSE_NATIVE_X11 #include @@ -221,6 +224,9 @@ static GLFWwindow* init(const char* glsl_version){ glfwMakeContextCurrent(window); glfwSwapInterval(1); // Enable vsync ImGui::CreateContext(); +#ifdef __linux__ + ImPlot::CreateContext(); +#endif ImGuiIO& io = ImGui::GetIO(); (void)io; io.IniFilename = NULL; ImGui::StyleColorsDark(); diff --git a/src/gl/gl_hud.cpp b/src/gl/gl_hud.cpp index 75029d35..3183fecc 100644 --- a/src/gl/gl_hud.cpp +++ b/src/gl/gl_hud.cpp @@ -8,6 +8,9 @@ #include #include #include +#ifdef __linux__ +#include +#endif #include "gl_hud.h" #include "file_utils.h" #include "notify.h" @@ -152,6 +155,9 @@ void imgui_create(void *ctx, const gl_wsi plat) IMGUI_CHECKVERSION(); ImGuiContext *saved_ctx = ImGui::GetCurrentContext(); state.imgui_ctx = ImGui::CreateContext(); +#ifdef __linux__ + ImPlot::CreateContext(); +#endif ImGuiIO& io = ImGui::GetIO(); (void)io; //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls diff --git a/src/meson.build b/src/meson.build index 537ce63c..7adb74f9 100644 --- a/src/meson.build +++ b/src/meson.build @@ -174,9 +174,11 @@ mangohud_static_lib = static_library( dep_pthread, dep_vulkan, windows_deps, - json_dep], + json_dep, + implot_dep], include_directories : [inc_common], link_args : link_args, + link_with : implot_lib, install_dir : libdir_mangohud, install : false ) @@ -215,9 +217,11 @@ mangohud_opengl_shared_lib = shared_library( dep_pthread, dep_vulkan, windows_deps, - json_dep], + json_dep, + implot_dep], include_directories : [inc_common], link_args : link_args, + link_with: mangohud_static_lib, install_dir : libdir_mangohud, install: true ) @@ -240,6 +244,7 @@ if is_unixy dependencies : [dep_dl], include_directories : [inc_common], link_args : link_args, + link_with: mangohud_static_lib, install_dir : libdir_mangohud, install : true ) @@ -270,6 +275,8 @@ if get_option('mangoapp') dep_x11, glfw3_dep, json_dep, + glew_dep, + implot_dep ], include_directories : [inc_common], install_tag : 'mangoapp', diff --git a/src/vulkan.cpp b/src/vulkan.cpp index a2c2b4ca..7d7010ac 100644 --- a/src/vulkan.cpp +++ b/src/vulkan.cpp @@ -50,6 +50,9 @@ #include "notify.h" #include "blacklist.h" #include "pci_ids.h" +#ifdef __linux__ +#include "implot.h" +#endif using namespace std; @@ -1310,6 +1313,9 @@ static void setup_swapchain_data(struct swapchain_data *data, data->format = pCreateInfo->imageFormat; data->imgui_context = ImGui::CreateContext(data->font_atlas); +#ifdef __linux__ + ImPlot::CreateContext(); +#endif ImGui::SetCurrentContext(data->imgui_context); ImGui::GetIO().IniFilename = NULL; diff --git a/subprojects/implot.wrap b/subprojects/implot.wrap new file mode 100644 index 00000000..45b02fbd --- /dev/null +++ b/subprojects/implot.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = implot-0.16 +source_url = https://github.com/epezent/implot/archive/refs/tags/v0.16.zip +source_filename = implot-0.16.zip +source_hash = 24f772c688f6b8a6e19d7efc10e4923a04a915f13d487b08b83553aa62ae1708 +patch_filename = implot_0.16-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/implot_0.16-1/get_patch +patch_hash = 1c6b1462066a5452fa50c1da1dd47fed841f28232972c82d778f2962936568c7 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/implot_0.16-1/implot-0.16.zip +wrapdb_version = 0.16-1 + +[provide] +implot = implot_dep