diff --git a/inferno/src/inferno/render/context.cpp b/inferno/src/inferno/render/context.cpp index 23b44f5..3fbf4ff 100644 --- a/inferno/src/inferno/render/context.cpp +++ b/inferno/src/inferno/render/context.cpp @@ -53,6 +53,10 @@ namespace Inferno { } void Context::update() + { + } + + void Context::render() { glfwSwapBuffers(m_window); } diff --git a/inferno/src/inferno/render/context.h b/inferno/src/inferno/render/context.h index c012705..e03a474 100644 --- a/inferno/src/inferno/render/context.h +++ b/inferno/src/inferno/render/context.h @@ -14,7 +14,7 @@ namespace Inferno { void initialize(); void update(); - // void render(); + void render(); void destroy(); // ----------------------------------------- diff --git a/inferno/src/inferno/window.cpp b/inferno/src/inferno/window.cpp index b488ac9..2bb88eb 100644 --- a/inferno/src/inferno/window.cpp +++ b/inferno/src/inferno/window.cpp @@ -7,6 +7,8 @@ #include "inferno/event/applicationevent.h" #include "inferno/event/keyevent.h" #include "inferno/event/mouseevent.h" +#include "inferno/input.h" +#include "inferno/inputcodes.h" #include "inferno/log.h" #include "inferno/render/context.h" #include "inferno/settings.h" @@ -18,7 +20,7 @@ namespace Inferno { Window::Window() { - m_windowProperties = { + m_properties = { Settings::get().window.title, Settings::get().window.width, Settings::get().window.height, @@ -38,9 +40,9 @@ namespace Inferno { void Window::initialize() { - const char* title = m_windowProperties.title; - unsigned int width = m_windowProperties.width; - unsigned int height = m_windowProperties.height; + const char* title = m_properties.title; + unsigned int width = m_properties.width; + unsigned int height = m_properties.height; // Only init once if (s_windowCount == 0) { @@ -88,8 +90,8 @@ namespace Inferno { glfwSetWindowSizeCallback(m_window, [](GLFWwindow* window, int width, int height) { Window& w = *(Window*)glfwGetWindowUserPointer(window); - w.m_windowProperties.width = width; - w.m_windowProperties.height = height; + w.m_properties.width = width; + w.m_properties.height = height; WindowResizeEvent event(width, height); w.m_eventCallback(event); @@ -163,7 +165,20 @@ namespace Inferno { void Window::update() { glfwPollEvents(); - m_context->update(); + + // Lock mouse in window + if (Input::isKeyPressed(KeyCode("GLFW_KEY_LEFT_SUPER"))) { + glfwSetInputMode(m_window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); + } + else { + glfwSetInputMode(m_window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); + } + + } + + void Window::render() + { + m_context->render(); } void Window::destroy() @@ -183,11 +198,11 @@ namespace Inferno { GLFWmonitor* monitor = glfwGetPrimaryMonitor(); int xPos = 0; int yPos = 0; - unsigned int width = m_windowProperties.width; - unsigned int height = m_windowProperties.height; + unsigned int width = m_properties.width; + unsigned int height = m_properties.height; int refresh = GLFW_DONT_CARE; - const char* fullscreen = m_windowProperties.fullscreen; + const char* fullscreen = m_properties.fullscreen; const GLFWvidmode* mode = glfwGetVideoMode(monitor); if (strcmp(fullscreen, "fullscreen") == 0) { diff --git a/inferno/src/inferno/window.h b/inferno/src/inferno/window.h index 66fdf4b..22414b2 100644 --- a/inferno/src/inferno/window.h +++ b/inferno/src/inferno/window.h @@ -27,7 +27,7 @@ namespace Inferno { void initialize(); void update(); - // void render(); + void render(); void destroy(); // ----------------------------------------- @@ -36,9 +36,10 @@ namespace Inferno { bool shouldClose() const; void setShouldClose(bool close) const; - inline int getWidth() const { return m_windowProperties.width; } - inline int getHeight() const { return m_windowProperties.height; } - inline bool isVSync() const { return m_windowProperties.vsync; } + inline int getAspect() const { return m_properties.width / m_properties.height; } + inline int getWidth() const { return m_properties.width; } + inline int getHeight() const { return m_properties.height; } + inline bool isVSync() const { return m_properties.vsync; } inline GLFWwindow* getWindow() const { return m_window; } inline Context* getContext() const { return m_context; } @@ -46,7 +47,7 @@ namespace Inferno { inline void setEventCallback(std::function callback) { m_eventCallback = callback; } private: - WindowProperties m_windowProperties; + WindowProperties m_properties; GLFWwindow* m_window; Context* m_context;