mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
fixing issue when creating multiple mlx application with leaks in the first one
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/20 00:57:15 by kiroussa ### ########.fr */
|
||||
/* Updated: 2023/12/27 17:19:50 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -31,6 +31,7 @@ typedef enum
|
||||
MLX_WINDOW_EVENT = 5
|
||||
} mlx_event_type;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes the MLX internal application
|
||||
*
|
||||
@@ -38,6 +39,7 @@ typedef enum
|
||||
*/
|
||||
MLX_API void* mlx_init();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Creates a new window
|
||||
*
|
||||
@@ -50,6 +52,7 @@ MLX_API void* mlx_init();
|
||||
*/
|
||||
MLX_API void* mlx_new_window(void* mlx, int w, int h, const char* title);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gives a function to be executed at each loop turn
|
||||
*
|
||||
@@ -59,9 +62,9 @@ MLX_API void* mlx_new_window(void* mlx, int w, int h, const char* title);
|
||||
*
|
||||
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
|
||||
*/
|
||||
|
||||
MLX_API int mlx_loop_hook(void* mlx, int (*f)(void*), void* param);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Starts the internal main loop
|
||||
*
|
||||
@@ -71,6 +74,7 @@ MLX_API int mlx_loop_hook(void* mlx, int (*f)(void*), void* param);
|
||||
*/
|
||||
MLX_API int mlx_loop(void* mlx);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Ends the internal main loop
|
||||
*
|
||||
@@ -80,6 +84,7 @@ MLX_API int mlx_loop(void* mlx);
|
||||
*/
|
||||
MLX_API int mlx_loop_end(void* mlx);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Shows mouse cursor
|
||||
*
|
||||
@@ -87,6 +92,7 @@ MLX_API int mlx_loop_end(void* mlx);
|
||||
*/
|
||||
MLX_API int mlx_mouse_show();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Hides mouse cursor
|
||||
*
|
||||
@@ -94,6 +100,7 @@ MLX_API int mlx_mouse_show();
|
||||
*/
|
||||
MLX_API int mlx_mouse_hide();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Moves cursor to givent position
|
||||
*
|
||||
@@ -106,6 +113,7 @@ MLX_API int mlx_mouse_hide();
|
||||
*/
|
||||
MLX_API int mlx_mouse_move(void* mlx, void* win, int x, int y);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get cursor's position
|
||||
*
|
||||
@@ -160,6 +168,7 @@ MLX_API int mlx_pixel_put(void* mlx, void* win, int x, int y, int color);
|
||||
*/
|
||||
MLX_API void* mlx_new_image(void* mlx, int width, int height);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get image pixel data
|
||||
*
|
||||
@@ -180,6 +189,7 @@ MLX_API void* mlx_new_image(void* mlx, int width, int height);
|
||||
*/
|
||||
MLX_API int mlx_get_image_pixel(void* mlx, void* img, int x, int y);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set image pixel data
|
||||
*
|
||||
@@ -201,6 +211,7 @@ MLX_API int mlx_get_image_pixel(void* mlx, void* img, int x, int y);
|
||||
*/
|
||||
MLX_API void mlx_set_image_pixel(void* mlx, void* img, int x, int y, int color);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Put image to the given window
|
||||
*
|
||||
@@ -214,6 +225,7 @@ MLX_API void mlx_set_image_pixel(void* mlx, void* img, int x, int y, int color);
|
||||
*/
|
||||
MLX_API int mlx_put_image_to_window(void* mlx, void* win, void* img, int x, int y);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Destroys internal image
|
||||
*
|
||||
@@ -237,6 +249,7 @@ MLX_API int mlx_destroy_image(void* mlx, void* img);
|
||||
*/
|
||||
MLX_API void* mlx_png_file_to_image(void* mlx, char* filename, int* width, int* height);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create a new image from a jpg file
|
||||
*
|
||||
@@ -249,6 +262,7 @@ MLX_API void* mlx_png_file_to_image(void* mlx, char* filename, int* width, int*
|
||||
*/
|
||||
MLX_API void* mlx_jpg_file_to_image(void* mlx, char* filename, int* width, int* height);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create a new image from a bmp file
|
||||
*
|
||||
@@ -288,6 +302,7 @@ MLX_API int mlx_string_put(void* mlx, void* win, int x, int y, int color, char*
|
||||
*/
|
||||
MLX_API void mlx_set_font(void* mlx, void* win, char* filepath);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Loads a font to be used by `mlx_string_put` and scales it
|
||||
*
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/24 08:56:33 by kbz_8 ### ########.fr */
|
||||
/* Updated: 2023/12/27 21:30:10 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace mlx::core
|
||||
|
||||
void Application::destroyTexture(void* ptr)
|
||||
{
|
||||
vkDeviceWaitIdle(Render_Core::get().getDevice().get()); // TODO : synchronize with another method than stopping all the GPU porcess
|
||||
vkDeviceWaitIdle(Render_Core::get().getDevice().get()); // TODO : synchronize with another method than stopping all the GPU process
|
||||
Texture* texture = static_cast<Texture*>(ptr);
|
||||
texture->destroy();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 17:42:32 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/11 19:46:57 by kbz_8 ### ########.fr */
|
||||
/* Updated: 2023/12/27 17:21:07 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/02 15:13:55 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/24 09:39:45 by kbz_8 ### ########.fr */
|
||||
/* Updated: 2023/12/27 21:27:48 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "renderer/images/texture.h"
|
||||
#include <core/graphics.h>
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 17:36:44 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/10 22:49:11 by kbz_8 ### ########.fr */
|
||||
/* Updated: 2023/12/27 16:57:28 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace mlx
|
||||
|
||||
MLX_Window::MLX_Window(std::size_t w, std::size_t h, const std::string& title) : _width(w), _height(h)
|
||||
{
|
||||
if(title.find("vvaas") != std::string::npos)
|
||||
core::error::report(e_kind::message, "vvaas est mauvais");
|
||||
_win = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN);
|
||||
if(!_win)
|
||||
core::error::report(e_kind::fatal_error, std::string("unable to open a new window, ") + SDL_GetError());
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: kbz_8 <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/10/20 22:02:37 by kbz_8 #+# #+# */
|
||||
/* Updated: 2023/12/16 19:14:15 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/12/27 21:31:04 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -17,11 +17,7 @@
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 0
|
||||
#define VMA_VULKAN_VERSION 1002000
|
||||
#ifdef DEBUG
|
||||
#define VMA_ASSERT(expr) (static_cast<bool>(expr) ? void(0) : mlx::core::error::report(e_kind::fatal_error, "Graphics allocator : an assertion has been catched : '%s'", #expr))
|
||||
#else
|
||||
#define VMA_ASSERT(expr) ((void)0)
|
||||
#endif
|
||||
#define VMA_ASSERT(expr) ((void)0)
|
||||
#define VMA_IMPLEMENTATION
|
||||
|
||||
#ifdef MLX_COMPILER_CLANG
|
||||
@@ -177,5 +173,7 @@ namespace mlx
|
||||
else if(_active_buffers_allocations != 0)
|
||||
core::error::report(e_kind::error, "Graphics allocator : some MLX-dependant allocations were not freed before destroying the display (%d active allocations), please report, this should not happen", _active_buffers_allocations);
|
||||
vmaDestroyAllocator(_allocator);
|
||||
_active_buffers_allocations = 0;
|
||||
_active_images_allocations = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/12/19 14:05:25 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/10 22:25:36 by kbz_8 ### ########.fr */
|
||||
/* Updated: 2023/12/28 01:01:03 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace mlx
|
||||
VkDebugUtilsMessengerCreateInfoEXT createInfo;
|
||||
populateDebugMessengerCreateInfo(createInfo);
|
||||
if(createDebugUtilsMessengerEXT(&createInfo, nullptr) != VK_SUCCESS)
|
||||
core::error::report(e_kind::error, "Vulkan : failed to set up debug messenger");
|
||||
core::error::report(e_kind::warning, "Vulkan : failed to set up debug messenger");
|
||||
#ifdef DEBUG
|
||||
else
|
||||
core::error::report(e_kind::message, "Vulkan : enabled validation layers");
|
||||
|
||||
Reference in New Issue
Block a user