From a556b45abf18f1bd509daaf63b66b7d55e9fd291 Mon Sep 17 00:00:00 2001 From: jjesswan Date: Mon, 22 Apr 2024 21:56:26 -0400 Subject: add engine version --- engine-ocean/Engine/window.cpp | 129 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 engine-ocean/Engine/window.cpp (limited to 'engine-ocean/Engine/window.cpp') diff --git a/engine-ocean/Engine/window.cpp b/engine-ocean/Engine/window.cpp new file mode 100644 index 0000000..f1d7637 --- /dev/null +++ b/engine-ocean/Engine/window.cpp @@ -0,0 +1,129 @@ +#include "window.h" + +Window::Window(){ + std::cout<<"Start"<update(difference); + m_core->draw(); + glfwSwapBuffers(m_GLFWwindow); + + } +} + +void Window::end(){ + glfwDestroyWindow(m_GLFWwindow); + glfwTerminate(); + exit(EXIT_SUCCESS); +} + +void Window::keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods){ + if(key == GLFW_KEY_ESCAPE){ + glfwSetWindowShouldClose(window, true); + } + Core* ptr = (Core*)glfwGetWindowUserPointer(window); + ptr->keyEvent(key, action); +} + +void Window::cursorPosCallback(GLFWwindow* window, double xpos, double ypos){ + Core* ptr = (Core*)glfwGetWindowUserPointer(window); + ptr->mousePosEvent(xpos, ypos); +} + +void Window::mouseButtonCallback(GLFWwindow* window, int button, int action, int mods){ + Core* ptr = (Core*)glfwGetWindowUserPointer(window); + ptr->mouseButtonEvent(button, action); +} + +void Window::scrollCallback(GLFWwindow* window, double xoffset, double yoffset){ + Core* ptr = (Core*)glfwGetWindowUserPointer(window); + ptr->scrollEvent(yoffset); +} + +void Window::windowSizeCallback(GLFWwindow* window, int width, int height){ + Core* ptr = (Core*)glfwGetWindowUserPointer(window); + ptr->windowResizeEvent(width, height); +} + +void Window::framebufferSizeCallback(GLFWwindow* window, int width, int height){ + Core* ptr = (Core*)glfwGetWindowUserPointer(window); + ptr->framebufferResizeEvent(width, height); +} -- cgit v1.2.3-70-g09d2