From 83432cb356f27202b9d871b8bc47dff2dfa528bd Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Sun, 15 Sep 2024 10:11:08 +0200 Subject: [PATCH] fixing warnings in kvf --- includes/mlx.h | 13 ++++++++++++- runtime/Includes/Core/Application.h | 1 + runtime/Includes/Core/Application.inl | 9 +++++++++ runtime/Includes/Core/SDLManager.h | 1 + runtime/Includes/Platform/Window.h | 1 + runtime/Sources/Core/Bridge.cpp | 6 ++++++ runtime/Sources/Core/SDLManager.cpp | 5 +++++ runtime/Sources/Renderer/RenderCore.cpp | 10 +++++++++- third_party/kvf.h | 1 + 9 files changed, 45 insertions(+), 2 deletions(-) diff --git a/includes/mlx.h b/includes/mlx.h index 14e4a0e..ef02780 100644 --- a/includes/mlx.h +++ b/includes/mlx.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */ -/* Updated: 2024/01/18 14:36:12 by maldavid ### ########.fr */ +/* Updated: 2024/09/15 09:23:48 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -54,6 +54,17 @@ MLX_API void* mlx_init(); MLX_API void* mlx_new_window(void* mlx, int w, int h, const char* title); +/** + * @brief Creates a new window + * + * @param mlx Internal MLX application + * @param win Internal window to move + * @param x New x position + * @param y New y position + * + */ +MLX_API void mlx_set_window_position(void *mlx, void *win, int x, int y); + /** * @brief Gives a function to be executed at each loop turn * diff --git a/runtime/Includes/Core/Application.h b/runtime/Includes/Core/Application.h index ec74102..213010b 100644 --- a/runtime/Includes/Core/Application.h +++ b/runtime/Includes/Core/Application.h @@ -25,6 +25,7 @@ namespace mlx inline Handle NewGraphicsSuport(std::size_t w, std::size_t h, const char* title); inline void ClearGraphicsSupport(Handle win); inline void DestroyGraphicsSupport(Handle win); + inline void SetGraphicsSupportPosition(Handle win, int x, int y); inline void PixelPut(Handle win, int x, int y, std::uint32_t color) const noexcept; inline void StringPut(Handle win, int x, int y, std::uint32_t color, char* str); diff --git a/runtime/Includes/Core/Application.inl b/runtime/Includes/Core/Application.inl index d537068..0296216 100644 --- a/runtime/Includes/Core/Application.inl +++ b/runtime/Includes/Core/Application.inl @@ -104,6 +104,15 @@ namespace mlx m_graphics.erase(m_graphics.begin() + *static_cast(win)); } + void Application::SetGraphicsSupportPosition(Handle win, int x, int y) + { + CHECK_WINDOW_PTR(win); + if(!m_graphics[*static_cast(win)]->HasWindow()) + Warning("trying to move a window that is targeting an image and not a real window, this is not allowed"); + else + m_graphics[*static_cast(win)]->GetWindow()->SetPosition(x, y); + } + void Application::PixelPut(Handle win, int x, int y, std::uint32_t color) const noexcept { MLX_PROFILE_FUNCTION(); diff --git a/runtime/Includes/Core/SDLManager.h b/runtime/Includes/Core/SDLManager.h index df49d13..8022a25 100644 --- a/runtime/Includes/Core/SDLManager.h +++ b/runtime/Includes/Core/SDLManager.h @@ -21,6 +21,7 @@ namespace mlx Vec2ui GetVulkanDrawableSize(Handle window) const noexcept; void MoveMouseOnWindow(Handle window, int x, int y) const noexcept; void GetScreenSizeWindowIsOn(Handle window, int* x, int* y) const noexcept; + void SetWindowPosition(Handle window, int x, int y) const noexcept; inline void SetEventCallback(func::function functor, void* userdata) { f_callback = std::move(functor); p_callback_data = userdata; } diff --git a/runtime/Includes/Platform/Window.h b/runtime/Includes/Platform/Window.h index 5895a70..427e52f 100644 --- a/runtime/Includes/Platform/Window.h +++ b/runtime/Includes/Platform/Window.h @@ -18,6 +18,7 @@ namespace mlx inline void MoveMouse(int x, int y) { SDLManager::Get().MoveMouseOnWindow(p_window, x, y); } inline void GetScreenSizeWindowIsOn(int* x, int* y) { SDLManager::Get().GetScreenSizeWindowIsOn(p_window, x, y); } + inline void SetPosition(int x, int y) { SDLManager::Get().SetWindowPosition(p_window, x, y); } inline VkSurfaceKHR CreateVulkanSurface(VkInstance instance) const noexcept { return SDLManager::Get().CreateVulkanSurface(p_window, instance); } inline std::vector GetRequiredVulkanInstanceExtentions() const noexcept { return SDLManager::Get().GetRequiredVulkanInstanceExtentions(p_window); } diff --git a/runtime/Sources/Core/Bridge.cpp b/runtime/Sources/Core/Bridge.cpp index deff1a2..3ba1a9e 100644 --- a/runtime/Sources/Core/Bridge.cpp +++ b/runtime/Sources/Core/Bridge.cpp @@ -45,6 +45,12 @@ extern "C" return static_cast(mlx)->NewGraphicsSuport(w, h, title); } + void mlx_set_window_position(void *mlx, void *win, int x, int y) + { + MLX_CHECK_APPLICATION_POINTER(mlx); + static_cast(mlx)->SetGraphicsSupportPosition(win, x, y); + } + int mlx_loop_hook(void* mlx, int (*f)(void*), void* param) { MLX_CHECK_APPLICATION_POINTER(mlx); diff --git a/runtime/Sources/Core/SDLManager.cpp b/runtime/Sources/Core/SDLManager.cpp index 8619340..36407bf 100644 --- a/runtime/Sources/Core/SDLManager.cpp +++ b/runtime/Sources/Core/SDLManager.cpp @@ -173,6 +173,11 @@ namespace mlx *y = DM.h; } + void SDLManager::SetWindowPosition(Handle window, int x, int y) const noexcept + { + SDL_SetWindowPosition(static_cast(window), x, y); + } + std::int32_t SDLManager::GetX() const noexcept { int dummy; diff --git a/runtime/Sources/Renderer/RenderCore.cpp b/runtime/Sources/Renderer/RenderCore.cpp index 989f138..0ab8904 100644 --- a/runtime/Sources/Renderer/RenderCore.cpp +++ b/runtime/Sources/Renderer/RenderCore.cpp @@ -1,3 +1,4 @@ +#include #include #define KVF_IMPLEMENTATION @@ -5,7 +6,14 @@ #define KVF_ENABLE_VALIDATION_LAYERS #endif -#include +#if defined(MLX_COMPILER_GCC) || defined(MLX_COMPILER_CLANG) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wmissing-field-initializers" + #include + #pragma clang diagnostic pop +#else + #include +#endif #include #include diff --git a/third_party/kvf.h b/third_party/kvf.h index 6a22d3e..5dd0758 100755 --- a/third_party/kvf.h +++ b/third_party/kvf.h @@ -1062,6 +1062,7 @@ void kvfAddLayer(const char* layer) strcpy(__kvf_extra_layers[__kvf_extra_layers_count], layer); __kvf_extra_layers_count++; #else + (void)layer; if(__kvf_validation_error_callback != NULL) { char buffer[4096];