adding clear window

This commit is contained in:
2023-04-01 17:51:29 +02:00
parent 28850a6cb8
commit 7eea6ea1d5
13 changed files with 62 additions and 26 deletions

View File

@@ -6,12 +6,13 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
/* Updated: 2023/04/01 15:34:00 by maldavid ### ########.fr */
/* Updated: 2023/04/01 16:03:45 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include "application.h"
#include <renderer/images/texture.h>
#include <renderer/core/render_core.h>
namespace mlx::core
{
@@ -47,12 +48,8 @@ namespace mlx::core
void Application::destroy_texture(void* ptr)
{
vkDeviceWaitIdle(Render_Core::get().getDevice().get());
TextureID id = *static_cast<TextureID*>(ptr);
_texture_lib.removeTextureFromLibrary(id);
}
Application::~Application()
{
_texture_lib.clearLibrary();
}
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
/* Updated: 2023/04/01 14:46:14 by maldavid ### ########.fr */
/* Updated: 2023/04/01 17:26:10 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -38,10 +38,17 @@ namespace mlx::core
return static_cast<void*>(&_wins.back()->get_id());
}
inline int get_mouse_pos(void* win_ptr, int* x, int* y) noexcept
inline void get_mouse_pos(int* x, int* y) noexcept
{
if(*static_cast<int*>(win_ptr) > _wins.size())
return -1;
*x = _in.getX();
*y = _in.getY();
}
inline void mouse_move(void* win_ptr, int x, int y) noexcept
{
SDL_WarpMouseInWindow(_wins[*static_cast<int*>(win_ptr)]->getNativeWindow(), x, y);
SDL_PumpEvents();
SDL_FlushEvent(SDL_MOUSEMOTION);
}
inline void loop_hook(int (*f)(void*), void* param) { _loop_hook = f; _param = param; }
@@ -53,11 +60,12 @@ namespace mlx::core
void texture_put(void* win, void* img, int x, int y);
void destroy_texture(void* ptr);
inline void clear_window(void* win_ptr) { _wins[*static_cast<int*>(win_ptr)]->clear(); }
inline void destroy_window(void* win_ptr) { _wins[*static_cast<int*>(win_ptr)].reset(); }
void run() noexcept;
~Application();
~Application() = default;
private:
Input _in;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
/* Updated: 2023/04/01 15:32:57 by maldavid ### ########.fr */
/* Updated: 2023/04/01 17:48:21 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -56,13 +56,15 @@ extern "C"
return SDL_ShowCursor(SDL_DISABLE);
}
int mlx_mouse_move(void* win_ptr, int x, int y)
int mlx_mouse_move(void* mlx, void* win_ptr, int x, int y)
{
static_cast<mlx::core::Application*>(mlx)->mouse_move(win_ptr, x, y);
return 0;
}
int mlx_mouse_get_pos(void* win_ptr, int* x, int* y)
int mlx_mouse_get_pos(void* mlx, int* x, int* y)
{
static_cast<mlx::core::Application*>(mlx)->get_mouse_pos(x, y);
return 0;
}
@@ -89,6 +91,12 @@ extern "C"
return 0;
}
int mlx_clear_window(void* mlx_ptr, void* win_ptr)
{
static_cast<mlx::core::Application*>(mlx_ptr)->clear_window(win_ptr);
return 0;
}
int mlx_destroy_window(void* mlx, void* win_ptr)
{
static_cast<mlx::core::Application*>(mlx)->destroy_window(win_ptr);