summary refs log tree commit diff
path: root/src/GFX/Window.cpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2024-02-15 11:33:11 +0100
committerMel <einebeere@gmail.com>2024-02-15 11:34:28 +0100
commit92f63bbdbfc214849c203511bbcb1be0a4865588 (patch)
treed82e1b31e583b5cc9538f61cad696dab5dbd84dc /src/GFX/Window.cpp
parent87ef308220addbe4406006ceb802a7364e6f1a05 (diff)
downloadmeowcraft-92f63bbdbfc214849c203511bbcb1be0a4865588.tar.zst
meowcraft-92f63bbdbfc214849c203511bbcb1be0a4865588.zip
Proper input system
Diffstat (limited to 'src/GFX/Window.cpp')
-rw-r--r--src/GFX/Window.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/GFX/Window.cpp b/src/GFX/Window.cpp
index 33e76d5..5c391c8 100644
--- a/src/GFX/Window.cpp
+++ b/src/GFX/Window.cpp
@@ -3,10 +3,12 @@
 #include "../Common/Assert.hpp"
 #include "../ThreadRole.hpp"
 #include "Window.hpp"
+#include "../Common/Casts.hpp"
+#include <string>
 
 namespace MC::GFX {
 
-Window::Window(const Char* title, U32 width, U32 height) {
+Window::Window(std::string const& title, U32 const width, U32 const height) {
     ASSERT_MAIN_THREAD();
     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
@@ -14,7 +16,7 @@ Window::Window(const Char* title, U32 width, U32 height) {
     glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
     glfwWindowHint(GLFW_DOUBLEBUFFER, GL_TRUE);
 
-    m_window = glfwCreateWindow(width, height, title, nullptr, nullptr);
+    m_window = glfwCreateWindow(TO(I32, width), TO(I32, height), title.c_str(), nullptr, nullptr);
     if (m_window == nullptr) {
         throw std::runtime_error("Failed to create window.");
     }
@@ -36,32 +38,20 @@ GLFWwindow* Window::get() const {
     return m_window;
 }
 
-void Window::close() {
+void Window::close() const {
     glfwSetWindowShouldClose(m_window, true);
 }
 
-Vector<2> Window::mouse_delta() {
-    return m_mouse.update(m_window);
-}
-
-Bool Window::key(I32 key, I32 type) const {
-    return glfwGetKey(m_window, key) == type;
-}
-
-Bool Window::mouse(I32 key, I32 type) const {
-    return glfwGetMouseButton(m_window, key) == type;
-}
-
-void Window::start_render() {
+void Window::start_render() const {
     glfwSwapBuffers(m_window);
 }
 
-void Window::poll_events() {
+void Window::poll_events() const {
     ASSERT_MAIN_THREAD();
     glfwPollEvents();
 }
 
-void Window::on_size_change(void (callback)(GLFWwindow*, I32, I32)) {
+void Window::on_size_change(void (callback)(GLFWwindow*, I32, I32)) const {
     glfwSetFramebufferSizeCallback(m_window, callback);
 }