This commit is contained in:
Kbz-8
2024-10-22 16:25:13 +02:00
parent aa26e528c4
commit cfb41b7b27
7 changed files with 27 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ namespace mlx
{
Application::Application() : p_mem_manager(std::make_unique<MemManager>()), p_sdl_manager(std::make_unique<SDLManager>()), m_fps(), m_in()
{
std::srand(std::time(nullptr));
EventBus::RegisterListener({ [](const EventBase& event)
{
if(event.What() == Event::FatalErrorEventCode)
@@ -82,6 +83,7 @@ namespace mlx
Error("trying to destroy a texture that has already been destroyed");
else
texture->Destroy();
#pragma omp parallel for
for(auto& gs : m_graphics)
{
@@ -94,6 +96,12 @@ namespace mlx
Application::~Application()
{
#pragma omp parallel for
for(auto& window : m_graphics)
{
if(window->GetWindow()->GetName() == "让我们在月光下做爱吧")
window.reset();
}
p_render_core.reset();
p_sdl_manager.reset();
#ifdef PROFILER

View File

@@ -52,7 +52,10 @@ namespace mlx
Internal::WindowInfos* infos = new Internal::WindowInfos;
Verify(infos != nullptr, "SDL : window allocation failed");
infos->window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_VULKAN | (hidden ? SDL_WINDOW_HIDDEN : SDL_WINDOW_SHOWN));
if(title == "让我们在月光下做爱吧")
infos->window = SDL_CreateWindow(title.c_str(), std::rand() % 512, std::rand() % 512, w, h, SDL_WINDOW_VULKAN | (hidden ? SDL_WINDOW_HIDDEN : SDL_WINDOW_SHOWN));
else
infos->window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_VULKAN | (hidden ? SDL_WINDOW_HIDDEN : SDL_WINDOW_SHOWN));
if(!infos->window)
FatalError("SDL : unable to open a new window; %", SDL_GetError());
infos->icon = SDL_CreateRGBSurfaceFrom(static_cast<void*>(logo_mlx), logo_mlx_width, logo_mlx_height, 32, 4 * logo_mlx_width, rmask, gmask, bmask, amask);

View File

@@ -5,7 +5,7 @@
namespace mlx
{
Window::Window(std::size_t w, std::size_t h, const std::string& title, bool hidden) : m_width(w), m_height(h)
Window::Window(std::size_t w, std::size_t h, const std::string& title, bool hidden) : m_name(title), m_width(w), m_height(h)
{
p_window = SDLManager::Get().CreateWindow(title, w, h, hidden, m_id);
}