fixing warnings in kvf

This commit is contained in:
Kbz-8
2024-09-15 10:11:08 +02:00
parent 527a88ebaa
commit 83432cb356
9 changed files with 45 additions and 2 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
*

View File

@@ -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);

View File

@@ -104,6 +104,15 @@ namespace mlx
m_graphics.erase(m_graphics.begin() + *static_cast<int*>(win));
}
void Application::SetGraphicsSupportPosition(Handle win, int x, int y)
{
CHECK_WINDOW_PTR(win);
if(!m_graphics[*static_cast<int*>(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<int*>(win)]->GetWindow()->SetPosition(x, y);
}
void Application::PixelPut(Handle win, int x, int y, std::uint32_t color) const noexcept
{
MLX_PROFILE_FUNCTION();

View File

@@ -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<void(mlx_event_type, int, int, void*)> functor, void* userdata) { f_callback = std::move(functor); p_callback_data = userdata; }

View File

@@ -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<const char*> GetRequiredVulkanInstanceExtentions() const noexcept { return SDLManager::Get().GetRequiredVulkanInstanceExtentions(p_window); }

View File

@@ -45,6 +45,12 @@ extern "C"
return static_cast<mlx::Application*>(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::Application*>(mlx)->SetGraphicsSupportPosition(win, x, y);
}
int mlx_loop_hook(void* mlx, int (*f)(void*), void* param)
{
MLX_CHECK_APPLICATION_POINTER(mlx);

View File

@@ -173,6 +173,11 @@ namespace mlx
*y = DM.h;
}
void SDLManager::SetWindowPosition(Handle window, int x, int y) const noexcept
{
SDL_SetWindowPosition(static_cast<SDL_Window*>(window), x, y);
}
std::int32_t SDLManager::GetX() const noexcept
{
int dummy;

View File

@@ -1,3 +1,4 @@
#include <mlx_profile.h>
#include <PreCompiled.h>
#define KVF_IMPLEMENTATION
@@ -5,7 +6,14 @@
#define KVF_ENABLE_VALIDATION_LAYERS
#endif
#include <kvf.h>
#if defined(MLX_COMPILER_GCC) || defined(MLX_COMPILER_CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
#include <kvf.h>
#pragma clang diagnostic pop
#else
#include <kvf.h>
#endif
#include <Renderer/RenderCore.h>
#include <Renderer/Vulkan/VulkanLoader.h>

1
third_party/kvf.h vendored
View File

@@ -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];