mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
yes
This commit is contained in:
@@ -26,7 +26,7 @@ namespace mlx
|
||||
|
||||
inline void SetFPSCap(std::uint32_t fps) noexcept;
|
||||
|
||||
inline Handle NewGraphicsSuport(std::size_t w, std::size_t h, const char* title);
|
||||
inline Handle NewGraphicsSuport(std::size_t w, std::size_t h, const char* title, bool is_resizable);
|
||||
inline void ClearGraphicsSupport(Handle win);
|
||||
inline void DestroyGraphicsSupport(Handle win);
|
||||
inline void SetGraphicsSupportPosition(Handle win, int x, int y);
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace mlx
|
||||
m_fps.SetMaxFPS(fps);
|
||||
}
|
||||
|
||||
void* Application::NewGraphicsSuport(std::size_t w, std::size_t h, const char* title)
|
||||
void* Application::NewGraphicsSuport(std::size_t w, std::size_t h, const char* title, bool is_resizable)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(m_image_registry.IsTextureKnown(reinterpret_cast<Texture*>(const_cast<char*>(title))))
|
||||
@@ -88,13 +88,13 @@ namespace mlx
|
||||
{
|
||||
for(std::size_t i = 0; i < 8; i++)
|
||||
{
|
||||
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(std::rand() % 1920, std::rand() % 1080, "让我们在月光下做爱吧", m_graphics.size()));
|
||||
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(std::rand() % 1920, std::rand() % 1080, "让我们在月光下做爱吧", m_graphics.size(), is_resizable));
|
||||
m_graphics.back()->GetWindow()->SetPosition(std::rand() % 1920, std::rand() % 1080);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, title, m_graphics.size()));
|
||||
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, title, m_graphics.size(), is_resizable));
|
||||
m_in.RegisterWindow(m_graphics.back()->GetWindow());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace mlx
|
||||
{
|
||||
public:
|
||||
GraphicsSupport(std::size_t w, std::size_t h, NonOwningPtr<Texture> render_target, int id);
|
||||
GraphicsSupport(std::size_t w, std::size_t h, std::string title, int id);
|
||||
GraphicsSupport(std::size_t w, std::size_t h, std::string title, int id, bool is_resizable);
|
||||
|
||||
[[nodiscard]] MLX_FORCEINLINE int& GetID() noexcept { return m_id; }
|
||||
[[nodiscard]] inline std::shared_ptr<Window> GetWindow() { return p_window; }
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace mlx
|
||||
public:
|
||||
SDLManager();
|
||||
|
||||
Handle CreateWindow(const std::string& title, std::size_t w, std::size_t h, bool hidden, std::int32_t& id);
|
||||
Handle CreateWindow(const std::string& title, std::size_t w, std::size_t h, bool hidden, std::int32_t& id, bool is_resizable);
|
||||
void DestroyWindow(Handle window) noexcept;
|
||||
|
||||
void InputsFetcher(func::function<void(mlx_event_type, int, int)> functor);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace mlx
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
Window(std::size_t w, std::size_t h, const std::string& title, bool hidden = false);
|
||||
Window(std::size_t w, std::size_t h, const std::string& title, bool is_resizable, bool hidden = false);
|
||||
|
||||
inline Handle GetWindowHandle() const noexcept { return p_window; }
|
||||
inline int GetWidth() const noexcept { return m_width; }
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <Renderer/RenderCore.h>
|
||||
#include <Renderer/Image.h>
|
||||
#include <Core/EventBus.h>
|
||||
#include <Renderer/Swapchain.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
@@ -16,46 +17,33 @@ namespace mlx
|
||||
|
||||
void Init(NonOwningPtr<Window> window);
|
||||
|
||||
bool BeginFrame();
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
|
||||
[[nodiscard]] inline VkSwapchainKHR GetSwapchain() const noexcept { return m_swapchain; }
|
||||
[[nodiscard]] inline VkSurfaceKHR GetSurface() const noexcept { return m_surface; }
|
||||
[[nodiscard]] inline VkSemaphore GetImageAvailableSemaphore(int index) const noexcept { return m_image_available_semaphores[index]; }
|
||||
[[nodiscard]] inline VkSemaphore GetRenderFinishedSemaphore(int index) const noexcept { return m_render_finished_semaphores[index]; }
|
||||
[[nodiscard]] inline VkCommandBuffer GetCommandBuffer(int index) const noexcept { return m_cmd_buffers[index]; }
|
||||
[[nodiscard]] inline VkCommandBuffer GetActiveCommandBuffer() const noexcept { return m_cmd_buffers[m_current_frame_index]; }
|
||||
[[nodiscard]] inline const std::vector<Image>& GetSwapchainImages() const { return m_swapchain_images; }
|
||||
[[nodiscard]] inline std::size_t& GetDrawCallsCounterRef() noexcept { return m_drawcalls; }
|
||||
[[nodiscard]] inline std::size_t& GetPolygonDrawnCounterRef() noexcept { return m_polygons_drawn; }
|
||||
[[nodiscard]] inline std::size_t GetSwapchainImageIndex() const noexcept { return m_swapchain_image_index; }
|
||||
[[nodiscard]] inline std::size_t GetCurrentFrameIndex() const noexcept { return m_current_frame_index; }
|
||||
[[nodiscard]] inline NonOwningPtr<Window> GetWindow() const noexcept { return p_window; }
|
||||
|
||||
MLX_FORCEINLINE constexpr void RequireFramebufferResize() noexcept { m_framebuffers_resize = true; }
|
||||
[[nodiscard]] inline const Swapchain& GetSwapchain() const noexcept { return m_swapchain; }
|
||||
|
||||
void Destroy() noexcept;
|
||||
|
||||
~Renderer() = default;
|
||||
|
||||
private:
|
||||
void CreateSwapchain();
|
||||
void DestroySwapchain();
|
||||
|
||||
private:
|
||||
Swapchain m_swapchain;
|
||||
std::array<VkSemaphore, MAX_FRAMES_IN_FLIGHT> m_image_available_semaphores;
|
||||
std::array<VkSemaphore, MAX_FRAMES_IN_FLIGHT> m_render_finished_semaphores;
|
||||
std::array<VkCommandBuffer, MAX_FRAMES_IN_FLIGHT> m_cmd_buffers;
|
||||
std::array<VkFence, MAX_FRAMES_IN_FLIGHT> m_cmd_fences;
|
||||
std::vector<Image> m_swapchain_images;
|
||||
NonOwningPtr<Window> p_window;
|
||||
VkSurfaceKHR m_surface = VK_NULL_HANDLE;
|
||||
VkSwapchainKHR m_swapchain = VK_NULL_HANDLE;
|
||||
std::uint32_t m_current_frame_index = 0;
|
||||
std::uint32_t m_swapchain_image_index = 0;
|
||||
std::size_t m_drawcalls = 0;
|
||||
std::size_t m_polygons_drawn = 0;
|
||||
bool m_framebuffers_resize = false;
|
||||
std::size_t m_drawcalls = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
43
runtime/Includes/Renderer/Swapchain.h
git.filemode.normal_file
43
runtime/Includes/Renderer/Swapchain.h
git.filemode.normal_file
@@ -0,0 +1,43 @@
|
||||
#ifndef __MLX_SWAPCHAIN__
|
||||
#define __MLX_SWAPCHAIN__
|
||||
|
||||
#include <Utils/NonOwningPtr.h>
|
||||
#include <Renderer/Image.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class Swapchain
|
||||
{
|
||||
public:
|
||||
Swapchain() = default;
|
||||
|
||||
void Init(NonOwningPtr<class Window> window);
|
||||
void AquireFrame(VkSemaphore signal);
|
||||
void Present(VkSemaphore wait) noexcept;
|
||||
void Destroy();
|
||||
|
||||
[[nodiscard]] inline VkSwapchainKHR Get() const noexcept { return m_swapchain; }
|
||||
[[nodiscard]] inline VkSurfaceKHR GetSurface() const noexcept { return m_surface; }
|
||||
[[nodiscard]] inline std::uint32_t GetImagesCount() const noexcept { return m_images_count; }
|
||||
[[nodiscard]] inline std::uint32_t GetMinImagesCount() const noexcept { return m_min_images_count; }
|
||||
[[nodiscard]] inline std::uint32_t GetImageIndex() const noexcept { return m_current_image_index; }
|
||||
[[nodiscard]] inline const std::vector<Image>& GetSwapchainImages() const { return m_swapchain_images; }
|
||||
|
||||
~Swapchain() = default;
|
||||
|
||||
private:
|
||||
void CreateSwapchain();
|
||||
|
||||
private:
|
||||
std::vector<Image> m_swapchain_images;
|
||||
VkSwapchainKHR m_swapchain = VK_NULL_HANDLE;
|
||||
VkSurfaceKHR m_surface = VK_NULL_HANDLE;
|
||||
NonOwningPtr<class Window> p_window;
|
||||
std::uint32_t m_images_count = 0;
|
||||
std::uint32_t m_min_images_count = 0;
|
||||
std::uint32_t m_current_image_index = 0;
|
||||
bool m_resize = false;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user