mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
fixing SDLManager
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
Application::Application() : m_render_core(), m_fps(), m_in()
|
||||
Application::Application() : m_fps(), m_in()
|
||||
{
|
||||
EventBus::RegisterListener({[](const EventBase& event)
|
||||
{
|
||||
@@ -18,6 +18,7 @@ namespace mlx
|
||||
|
||||
m_fps.Init();
|
||||
SDLManager::Get().Init();
|
||||
p_render_core = std::make_unique<RenderCore>();
|
||||
}
|
||||
|
||||
void Application::Run() noexcept
|
||||
@@ -87,6 +88,7 @@ namespace mlx
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
p_render_core.reset();
|
||||
SDLManager::Get().Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace mlx
|
||||
constexpr const std::uint32_t amask = 0xff000000;
|
||||
#endif
|
||||
|
||||
namespace details
|
||||
namespace Internal
|
||||
{
|
||||
struct WindowInfos
|
||||
{
|
||||
@@ -101,9 +101,9 @@ namespace mlx
|
||||
DebugLog("SDL Manager initialized");
|
||||
}
|
||||
|
||||
void* SDLManager::CreateWindow(const std::string& title, std::size_t w, std::size_t h, bool hidden)
|
||||
Handle SDLManager::CreateWindow(const std::string& title, std::size_t w, std::size_t h, bool hidden)
|
||||
{
|
||||
details::WindowInfos* infos = new details::WindowInfos;
|
||||
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));
|
||||
@@ -117,11 +117,11 @@ namespace mlx
|
||||
return infos;
|
||||
}
|
||||
|
||||
void SDLManager::DestroyWindow(void* window) noexcept
|
||||
void SDLManager::DestroyWindow(Handle 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);
|
||||
Internal::WindowInfos* infos = static_cast<Internal::WindowInfos*>(window);
|
||||
if(infos->window != nullptr)
|
||||
SDL_DestroyWindow(infos->window);
|
||||
if(infos->icon != nullptr)
|
||||
@@ -134,7 +134,7 @@ namespace mlx
|
||||
VkSurfaceKHR SDLManager::CreateVulkanSurface(Handle window, VkInstance instance) const noexcept
|
||||
{
|
||||
VkSurfaceKHR surface;
|
||||
if(!SDL_Vulkan_CreateSurface(static_cast<SDL_Window*>(window), instance, &surface))
|
||||
if(!SDL_Vulkan_CreateSurface(static_cast<Internal::WindowInfos*>(window)->window, instance, &surface))
|
||||
FatalError("SDL : could not create a Vulkan surface; %", SDL_GetError());
|
||||
return surface;
|
||||
}
|
||||
@@ -169,27 +169,27 @@ namespace mlx
|
||||
Vec2ui SDLManager::GetVulkanDrawableSize(Handle window) const noexcept
|
||||
{
|
||||
Vec2i extent;
|
||||
SDL_Vulkan_GetDrawableSize(static_cast<SDL_Window*>(window), &extent.x, &extent.y);
|
||||
SDL_Vulkan_GetDrawableSize(static_cast<Internal::WindowInfos*>(window)->window, &extent.x, &extent.y);
|
||||
return Vec2ui{ extent };
|
||||
}
|
||||
|
||||
void SDLManager::MoveMouseOnWindow(Handle window, int x, int y) const noexcept
|
||||
{
|
||||
SDL_WarpMouseInWindow(static_cast<SDL_Window*>(window), x, y);
|
||||
SDL_WarpMouseInWindow(static_cast<Internal::WindowInfos*>(window)->window, x, y);
|
||||
SDL_PumpEvents();
|
||||
}
|
||||
|
||||
void SDLManager::GetScreenSizeWindowIsOn(Handle window, int* x, int* y) const noexcept
|
||||
{
|
||||
SDL_DisplayMode DM;
|
||||
SDL_GetDesktopDisplayMode(SDL_GetWindowDisplayIndex(static_cast<SDL_Window*>(window)), &DM);
|
||||
SDL_GetDesktopDisplayMode(SDL_GetWindowDisplayIndex(static_cast<Internal::WindowInfos*>(window)->window), &DM);
|
||||
*x = DM.w;
|
||||
*y = DM.h;
|
||||
}
|
||||
|
||||
void SDLManager::SetWindowPosition(Handle window, int x, int y) const noexcept
|
||||
{
|
||||
SDL_SetWindowPosition(static_cast<SDL_Window*>(window), x, y);
|
||||
SDL_SetWindowPosition(static_cast<Internal::WindowInfos*>(window)->window, x, y);
|
||||
}
|
||||
|
||||
std::int32_t SDLManager::GetX() const noexcept
|
||||
|
||||
@@ -27,19 +27,19 @@ namespace mlx
|
||||
|
||||
void ErrorCallback(const char* message) noexcept
|
||||
{
|
||||
FatalError(message, 0, "", "");
|
||||
Logs::Report(LogType::FatalError, 0, "", "", message);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void ValidationErrorCallback(const char* message) noexcept
|
||||
{
|
||||
Error(message, 0, "", "");
|
||||
Logs::Report(LogType::Error, 0, "", "", message);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void ValidationWarningCallback(const char* message) noexcept
|
||||
{
|
||||
Warning(message, 0, "", "");
|
||||
Logs::Report(LogType::Warning, 0, "", "", message);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user