fixing allocation issues with texts

This commit is contained in:
Kbz-8
2024-01-18 13:57:41 +01:00
parent a0b536483a
commit 58e687c952
28 changed files with 303 additions and 134 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: 2024/01/11 05:08:42 by maldavid ### ########.fr */
/* Updated: 2024/01/18 09:44:26 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include "application.h"
#include <renderer/texts/text_library.h>
#include <renderer/texts/font_library.h>
#include <SDL2/SDL.h>
#include <renderer/images/texture.h>
#include <renderer/core/render_core.h>
@@ -84,6 +85,7 @@ namespace mlx::core
Application::~Application()
{
TextLibrary::get().clearLibrary();
FontLibrary::get().clearLibrary();
if(__drop_sdl_responsability)
return;
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_EVENTS);

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
/* Updated: 2024/01/10 19:57:12 by maldavid ### ########.fr */
/* Updated: 2024/01/18 09:56:04 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -39,7 +39,7 @@ namespace mlx::core
inline void onEvent(void* win, int event, int (*funct_ptr)(int, void*), void* param) noexcept;
inline void getScreenSize(int* w, int* h) noexcept;
inline void getScreenSize(void* win, int* w, int* h) noexcept;
inline void* newGraphicsSuport(std::size_t w, std::size_t h, const char* title);
inline void clearGraphicsSupport(void* win);

View File

@@ -55,10 +55,11 @@ namespace mlx::core
_in->onEvent(_graphics[*static_cast<int*>(win)]->getWindow()->getID(), event, funct_ptr, param);
}
void Application::getScreenSize(int* w, int* h) noexcept
void Application::getScreenSize(void* win, int* w, int* h) noexcept
{
CHECK_WINDOW_PTR(win);
SDL_DisplayMode DM;
SDL_GetDesktopDisplayMode(0, &DM);
SDL_GetDesktopDisplayMode(SDL_GetWindowDisplayIndex(_graphics[*static_cast<int*>(win)]->getWindow()->getNativeWindow()), &DM);
*w = DM.w;
*h = DM.h;
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
/* Updated: 2024/01/16 08:20:17 by maldavid ### ########.fr */
/* Updated: 2024/01/18 09:55:53 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -271,10 +271,10 @@ extern "C"
return 0;
}
int mlx_get_screens_size(void* mlx, int* w, int* h)
int mlx_get_screens_size(void* mlx, void* win, int* w, int* h)
{
MLX_CHECK_APPLICATION_POINTER(mlx);
static_cast<mlx::core::Application*>(mlx)->getScreenSize(w, h);
static_cast<mlx::core::Application*>(mlx)->getScreenSize(win, w, h);
return 0;
}
}