mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
begenning the refactor
This commit is contained in:
47
runtime/Sources/Renderer/Core/Surface.cpp
git.filemode.normal_file
47
runtime/Sources/Renderer/Core/Surface.cpp
git.filemode.normal_file
@@ -0,0 +1,47 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* vk_surface.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/08 18:58:49 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/25 22:25:55 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <pre_compiled.h>
|
||||
#include "render_core.h"
|
||||
#include <platform/window.h>
|
||||
#include <renderer/renderer.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
void Surface::create(Renderer& renderer)
|
||||
{
|
||||
if(glfwCreateWindowSurface(Render_Core::get().getInstance().get(), renderer.getWindow()->getNativeWindow(), NULL, &_surface) != VK_SUCCESS)
|
||||
core::error::report(e_kind::fatal_error, "Vulkan : failed to create a surface");
|
||||
#ifdef DEBUG
|
||||
core::error::report(e_kind::message, "Vulkan : created new surface");
|
||||
#endif
|
||||
}
|
||||
|
||||
VkSurfaceFormatKHR Surface::chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats)
|
||||
{
|
||||
auto it = std::find_if(availableFormats.begin(), availableFormats.end(), [](VkSurfaceFormatKHR format)
|
||||
{
|
||||
return format.format == VK_FORMAT_R8G8B8A8_SRGB && format.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||
});
|
||||
|
||||
return (it == availableFormats.end() ? availableFormats[0] : *it);
|
||||
}
|
||||
|
||||
void Surface::destroy() noexcept
|
||||
{
|
||||
vkDestroySurfaceKHR(Render_Core::get().getInstance().get(), _surface, nullptr);
|
||||
_surface = VK_NULL_HANDLE;
|
||||
#ifdef DEBUG
|
||||
core::error::report(e_kind::message, "Vulkan : destroyed a surface");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user