mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
removing GLFW support
This commit is contained in:
9
Makefile
9
Makefile
@@ -6,7 +6,7 @@
|
||||
# By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2022/10/04 16:43:41 by maldavid #+# #+# #
|
||||
# Updated: 2024/03/27 21:30:44 by maldavid ### ########.fr #
|
||||
# Updated: 2024/05/25 16:08:57 by maldavid ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@@ -16,7 +16,6 @@ SRCS = $(wildcard $(addsuffix /*.cpp, ./runtime/Sources/Core))
|
||||
SRCS += $(wildcard $(addsuffix /*.cpp, ./runtime/Sources/Platform))
|
||||
SRCS += $(wildcard $(addsuffix /*.cpp, ./runtime/Sources/Renderer))
|
||||
SRCS += $(wildcard $(addsuffix /*.cpp, ./runtime/Sources/Renderer/**))
|
||||
SRCS += $(wildcard $(addsuffix /*.cpp, ./runtime/Sources/Drivers/**))
|
||||
|
||||
OBJ_DIR = objs/makefile
|
||||
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o))
|
||||
@@ -31,7 +30,7 @@ IMAGES_OPTIMIZED ?= true
|
||||
FORCE_INTEGRATED_GPU ?= false
|
||||
GRAPHICS_MEMORY_DUMP ?= false
|
||||
PROFILER ?= false
|
||||
LEGACY ?= false
|
||||
FORCE_WAYLAND ?= false
|
||||
|
||||
MODE = "release"
|
||||
|
||||
@@ -73,8 +72,8 @@ ifeq ($(PROFILER), true)
|
||||
CXXFLAGS += -D PROFILER
|
||||
endif
|
||||
|
||||
ifeq ($(LEGACY), true)
|
||||
CXXFLAGS += -D LEGACY
|
||||
ifeq ($(FORCE_WAYLAND), true)
|
||||
CXXFLAGS += -D FORCE_WAYLAND
|
||||
endif
|
||||
|
||||
RM = rm -rf
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/21 20:39:33 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/05/25 15:26:36 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include <Core/Graphics.h>
|
||||
#include <Platform/Inputs.h>
|
||||
#include <Core/DriverLoader.h>
|
||||
#include <Core/ImagesRegistry.h>
|
||||
#include <Core/Fps.h>
|
||||
|
||||
@@ -61,7 +60,6 @@ namespace mlx
|
||||
private:
|
||||
FpsManager m_fps;
|
||||
Input m_in;
|
||||
DriverLoader m_driver_loader;
|
||||
ImageRegistry m_image_registry;
|
||||
std::vector<std::unique_ptr<GraphicsSupport>> m_graphics;
|
||||
std::function<int(void*)> f_loop_hook;
|
||||
@@ -69,6 +67,6 @@ namespace mlx
|
||||
};
|
||||
}
|
||||
|
||||
#include <core/application.inl>
|
||||
#include <Core/Application.inl>
|
||||
|
||||
#endif // __MLX_APPLICATION__
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/* **************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* DriverLoader.inl :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/03 14:55:01 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/03 14:55:01 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* **************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#include <Core/DriverLoader.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
template <typename T>
|
||||
bool DriverLoader::LoadDriver()
|
||||
{
|
||||
m_instances.emplace_back(new T)->InitDriver();
|
||||
}
|
||||
|
||||
void DriverLoader::ShutdownAllDrivers()
|
||||
{
|
||||
for(auto& driver : m_instances)
|
||||
driver->ShutdownDriver();
|
||||
m_instances.clear();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/02 14:49:49 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/23 14:02:48 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/05/25 01:00:10 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -70,6 +70,6 @@ namespace mlx
|
||||
};
|
||||
}
|
||||
|
||||
#include <core/graphics.inl>
|
||||
#include <Core/Graphics.inl>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,39 +1,41 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* DriverLoader.h :+: :+: :+: */
|
||||
/* SDLManager.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/02 16:56:10 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/03 15:02:44 by maldavid ### ########.fr */
|
||||
/* Created: 2024/05/25 15:28:59 by maldavid #+# #+# */
|
||||
/* Updated: 2024/05/25 16:11:50 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_CORE_DRIVER_LOADER__
|
||||
#define __MLX_CORE_DRIVER_LOADER__
|
||||
#ifndef __MLX_SDL_MANAGER__
|
||||
#define __MLX_SDL_MANAGER__
|
||||
|
||||
#include <Drivers/DriverInstance.h>
|
||||
#include <Utils/Singleton.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class DriverLoader
|
||||
class SDLManager : public Singleton<SDLManager>
|
||||
{
|
||||
friend class Singleton<SDLManager>;
|
||||
|
||||
public:
|
||||
DriverLoader() = default;
|
||||
void Init() noexcept;
|
||||
void Shutdown() noexcept;
|
||||
|
||||
template <typename T>
|
||||
inline bool LoadDriver();
|
||||
|
||||
inline void ShutdownAllDrivers();
|
||||
|
||||
~DriverLoader() = default;
|
||||
void* CreateWindow(const std::string& title, std::size_t w, std::size_t h);
|
||||
void DestroyWindow(void* window) noexcept;
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<DriverInstance> > m_instances;
|
||||
SDLManager() = default;
|
||||
~SDLManager() = default;
|
||||
|
||||
private:
|
||||
std::unordered_set<void*> m_windows_registry;
|
||||
bool m_drop_sdl_responsability = false;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Core/DriverLoader.inl>
|
||||
|
||||
#endif
|
||||
@@ -1,35 +0,0 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* DriverInstance.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/02 16:57:20 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/02 17:01:03 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_DRIVER_INSTANCE__
|
||||
#define __MLX_DRIVER_INSTANCE__
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class DriverInstance
|
||||
{
|
||||
public:
|
||||
DriverInstance() = default;
|
||||
|
||||
virtual bool InitDriver() { m_is_up = true; return true; }
|
||||
virtual void ShutdownDriver() { m_is_up = false; }
|
||||
|
||||
inline bool IsRunning() const noexcept { return m_is_up; }
|
||||
|
||||
virtual ~DriverInstance() = default;
|
||||
|
||||
private:
|
||||
bool m_is_up = false;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* GLFWDriverInstance.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/02 17:01:51 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/02 17:04:12 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_GLFW_DRIVER_INSTANCE__
|
||||
#define __MLX_GLFW_DRIVER_INSTANCE__
|
||||
|
||||
#include <Drivers/DriverInstance.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class GLFWDriverInstance : public DriverInstance
|
||||
{
|
||||
public:
|
||||
GLFWDriverInstance() = default;
|
||||
|
||||
inline bool InitDriver() override;
|
||||
inline void ShutdownDriver() override;
|
||||
|
||||
~GLFWDriverInstance() override = default;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Drivers/GLFW/GLFWDriverInstance.inl>
|
||||
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
/* **************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* GLFWDriverInstance.inl :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/02 17:04:23 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/02 17:04:23 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* **************************************************************************** */
|
||||
|
||||
#include <Drivers/GLFW/GLFWDriverInstance.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
bool GLFWDriverInstance::InitDriver()
|
||||
{
|
||||
glfwSetErrorCallback([]([[maybe_unused]] int code, const char* desc)
|
||||
{
|
||||
FatalError("GLFW Driver Error : %", desc);
|
||||
});
|
||||
glfwInit();
|
||||
DebugLog("GLFW Driver loaded");
|
||||
}
|
||||
|
||||
void GLFWDriverInstance::ShutdownDriver()
|
||||
{
|
||||
glfwTerminate();
|
||||
DebugLog("GLFW Driver shutted down");
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* GLFWInputs.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/27 18:32:29 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 18:37:58 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_GLFW_INPUTS__
|
||||
#define __MLX_GLFW_INPUTS__
|
||||
|
||||
#include <Platform/Inputs.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class GLFWInputs : public Inputs
|
||||
{
|
||||
public:
|
||||
GLFWInputs() = default;
|
||||
|
||||
void Update() override noexcept;
|
||||
|
||||
void RegisterWindow(std::shared_ptr<Window> window) override;
|
||||
|
||||
inline std::int32_t GetX() override const noexcept { return m_x; }
|
||||
inline std::int32_t GetY() override const noexcept { return m_y; }
|
||||
inline std::int32_t GetXRel() override const noexcept { return m_x_rel; }
|
||||
inline std::int32_t GetYRel() override const noexcept { return m_y_rel; }
|
||||
|
||||
~GLFWInputs() override = default;
|
||||
|
||||
private:
|
||||
std::int32_t m_x = 0;
|
||||
std::int32_t m_y = 0;
|
||||
std::int32_t m_x_rel = 0;
|
||||
std::int32_t m_y_rel = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 21:53:12 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 21:58:18 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/05/25 16:11:00 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,18 +15,12 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
#ifdef LEGACY
|
||||
using WindowHandle = SDL_Window;
|
||||
#else
|
||||
using WindowHandle = GLFWwindow;
|
||||
#endif
|
||||
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
Window(std::size_t w, std::size_t h, const std::string& title);
|
||||
|
||||
inline NonOwningPtr<WindowHandle> GetWindowHandle() const noexcept = 0;
|
||||
inline void* GetWindowHandle() const noexcept { return p_window; }
|
||||
inline int GetWidth() const noexcept { return m_width; }
|
||||
inline int GetHeight() const noexcept { return m_height; }
|
||||
inline std::uint32_t GetID() const noexcept { return m_id; }
|
||||
@@ -36,6 +30,7 @@ namespace mlx
|
||||
~Window() = default;
|
||||
|
||||
private:
|
||||
void* p_window = nullptr;
|
||||
std::uint32_t m_id = -1;
|
||||
int m_width = 0;
|
||||
int m_height = 0;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/25 17:37:23 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/23 13:49:52 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/05/25 15:46:37 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -23,12 +23,8 @@
|
||||
#include <iostream>
|
||||
#include <volk.h>
|
||||
|
||||
#ifdef MLX_LEGACY
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_vulkan.h>
|
||||
#else
|
||||
#include <GLFW/glfw3.h>
|
||||
#endif
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_vulkan.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace mlx
|
||||
{
|
||||
template<typename T>
|
||||
NonOwningPtr<T>::NonOwningPtr(T* ptr) : p_ptr(ptr) {}
|
||||
|
||||
|
||||
template<typename T>
|
||||
NonOwningPtr<T>::NonOwningPtr(NonOwningPtr<T>&& ptr) noexcept : p_ptr(ptr.p_ptr)
|
||||
{
|
||||
@@ -28,7 +28,7 @@ namespace mlx
|
||||
{
|
||||
p_ptr = ptr;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
NonOwningPtr<T>& NonOwningPtr<T>::operator=(NonOwningPtr&& ptr) noexcept
|
||||
{
|
||||
@@ -47,13 +47,13 @@ namespace mlx
|
||||
{
|
||||
return p_ptr;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T* NonOwningPtr<T>::operator->() const noexcept
|
||||
{
|
||||
return p_ptr;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T& NonOwningPtr<T>::operator*() const noexcept
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/23 15:06:26 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/05/25 16:06:57 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <Renderer/Core/RenderCore.h>
|
||||
#include <Core/Memory.h>
|
||||
#include <Core/EventBus.h>
|
||||
#include <Core/SDLManager.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
@@ -29,6 +30,7 @@ namespace mlx
|
||||
}, "__internal_application" });
|
||||
|
||||
m_fps.init();
|
||||
SDLManager::Get().Init();
|
||||
}
|
||||
|
||||
void Application::Run() noexcept
|
||||
@@ -111,5 +113,6 @@ namespace mlx
|
||||
{
|
||||
TextLibrary::Get().ClearLibrary();
|
||||
FontLibrary::Get().ClearLibrary();
|
||||
SDLManager::Get().Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
94
runtime/Sources/Core/SDLManager.cpp
git.filemode.normal_file
94
runtime/Sources/Core/SDLManager.cpp
git.filemode.normal_file
@@ -0,0 +1,94 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* SDLManager.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:44:03 by maldavid #+# #+# */
|
||||
/* Updated: 2024/05/25 16:46:48 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <PreCompiled.h>
|
||||
#include <Core/SDLManager.h>
|
||||
#include <Core/Memory.h>
|
||||
#include <Utils/IconMlx.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
constexpr const std::uint32_t rmask = 0xff000000;
|
||||
constexpr const std::uint32_t gmask = 0x00ff0000;
|
||||
constexpr const std::uint32_t bmask = 0x0000ff00;
|
||||
constexpr const std::uint32_t amask = 0x000000ff;
|
||||
#else
|
||||
constexpr const std::uint32_t rmask = 0x000000ff;
|
||||
constexpr const std::uint32_t gmask = 0x0000ff00;
|
||||
constexpr const std::uint32_t bmask = 0x00ff0000;
|
||||
constexpr const std::uint32_t amask = 0xff000000;
|
||||
#endif
|
||||
|
||||
namespace details
|
||||
{
|
||||
struct WindowInfos
|
||||
{
|
||||
SDL_Window* window;
|
||||
SDL_Surface* icon;
|
||||
};
|
||||
}
|
||||
|
||||
void SDLManager::Init() noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
m_drop_sdl_responsability = SDL_WasInit(SDL_INIT_VIDEO);
|
||||
if(m_drop_sdl_responsability) // is case the mlx is running in a sandbox like MacroUnitTester where SDL is already init
|
||||
return;
|
||||
SDL_SetMemoryFunctions(MemManager::malloc, MemManager::calloc, MemManager::realloc, MemManager::free);
|
||||
|
||||
#ifdef FORCE_WAYLAND
|
||||
SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");
|
||||
#endif
|
||||
|
||||
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) != 0)
|
||||
FatalError("SDL : unable to init all subsystems; %", SDL_GetError());
|
||||
}
|
||||
|
||||
void* SDLManager::CreateWindow(const std::string& title, std::size_t w, std::size_t h)
|
||||
{
|
||||
details::WindowInfos* infos = new details::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 | 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);
|
||||
SDL_SetWindowIcon(infos->window, infos->icon);
|
||||
|
||||
m_windows_registry.insert(infos);
|
||||
|
||||
return infos;
|
||||
}
|
||||
|
||||
void SDLManager::DestroyWindow(void* window) noexcept
|
||||
{
|
||||
Verify(m_windows_registry.find(window) != m_windows_registry.end(), "SDL : cannot destroy window; unknown window pointer");
|
||||
|
||||
details::WindowInfos* infos = static_cast<details::WindowInfos*>(window);
|
||||
if(infos->window != nullptr)
|
||||
SDL_DestroyWindow(infos->window);
|
||||
if(infos->icon != nullptr)
|
||||
SDL_FreeSurface(infos->icon);
|
||||
|
||||
m_windows_registry.erase(infos);
|
||||
delete infos;
|
||||
}
|
||||
|
||||
void SDLManager::Shutdown() noexcept
|
||||
{
|
||||
if(m_drop_sdl_responsability)
|
||||
return;
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_EVENTS);
|
||||
SDL_Quit();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* GLFWInputs.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/27 18:39:32 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 18:42:18 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <PreCompiled.h>
|
||||
#include <Drivers/GLFW/GLFWInputs.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
void GLFWInputs::Update() noexcept
|
||||
{
|
||||
glfwPollEvents();
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* window.cpp :+: :+: :+: */
|
||||
/* Window.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 17:36:44 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/26 23:03:59 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/05/25 16:13:31 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <pre_compiled.h>
|
||||
#include <PreCompiled.h>
|
||||
|
||||
#include <platform/window.h>
|
||||
#include <core/errors.h>
|
||||
#include <utils/icon_mlx.h>
|
||||
#include <Core/SDLManager.h>
|
||||
#include <Platform/Window.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
Window::Window(std::size_t w, std::size_t h, const std::string& title) : _width(w), _height(h)
|
||||
Window::Window(std::size_t w, std::size_t h, const std::string& title) : m_width(w), m_height(h)
|
||||
{
|
||||
static std::uint64_t ids = 0;
|
||||
|
||||
if(title.find("vvaas") != std::string::npos)
|
||||
core::error::report(e_kind::message, "vvaas est mauvais");
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
_win = glfwCreateWindow(_width, _height, title.c_str(), NULL, NULL);;
|
||||
_id = ids++;
|
||||
Message("vvaas est mauvais");
|
||||
p_window = SDLManager::Get().CreateWindow(title, w, h);
|
||||
m_id = ids++;
|
||||
}
|
||||
|
||||
void Window::destroy() noexcept
|
||||
void Window::Destroy() noexcept
|
||||
{
|
||||
if(_win != nullptr)
|
||||
if(p_window != nullptr)
|
||||
{
|
||||
glfwDestroyWindow(_win);
|
||||
_win = nullptr;
|
||||
SDLManager::Get().DestroyWindow(p_window);
|
||||
p_window = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user