summary refs log tree commit diff
path: root/src/GFX/Window.cpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2024-02-12 12:55:11 +0100
committerMel <einebeere@gmail.com>2024-02-12 12:55:11 +0100
commitd2b5fc5b3bc648afffa42375706429685ac63794 (patch)
treea2dfbb241e1d46e5616c5884e5f3d685de2a2cb6 /src/GFX/Window.cpp
parent588c7e87b7cab270698d43ca5c22d67793ae5fc4 (diff)
downloadmeowcraft-d2b5fc5b3bc648afffa42375706429685ac63794.tar.zst
meowcraft-d2b5fc5b3bc648afffa42375706429685ac63794.zip
Split rendering into own thread and sync through render action lists
Diffstat (limited to 'src/GFX/Window.cpp')
-rw-r--r--src/GFX/Window.cpp18
1 files changed, 16 insertions, 2 deletions
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);
+}
+
+}