From d2b5fc5b3bc648afffa42375706429685ac63794 Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 12 Feb 2024 12:55:11 +0100 Subject: Split rendering into own thread and sync through render action lists --- src/GFX/Window.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/GFX/Window.cpp') diff --git a/src/GFX/Window.cpp b/src/GFX/Window.cpp index bbe2ba7..c0c5b03 100644 --- a/src/GFX/Window.cpp +++ b/src/GFX/Window.cpp @@ -2,6 +2,8 @@ #include "../Common/Sizes.hpp" #include "Window.hpp" +#include "../Common/Assert.hpp" + namespace MC::GFX { Window::Window(const Char* title, U32 width, U32 height) { @@ -48,8 +50,11 @@ Bool Window::mouse(I32 key, I32 type) const { return glfwGetMouseButton(m_window, key) == type; } -void Window::start_frame() { +void Window::start_render() { glfwSwapBuffers(m_window); +} + +void Window::poll_events() { glfwPollEvents(); } @@ -57,4 +62,13 @@ void Window::on_size_change(void (callback)(GLFWwindow*, I32, I32)) { glfwSetFramebufferSizeCallback(m_window, callback); } -} \ No newline at end of file +void Window::attach() const { + glfwMakeContextCurrent(m_window); +} + +void Window::detach() const { + ASSERT(glfwGetCurrentContext() == m_window, "Cannot detach window that is not current"); + glfwMakeContextCurrent(nullptr); +} + +} -- cgit 1.4.1