diff --git a/CMakeLists.txt b/CMakeLists.txt index 98d21fa..df57f71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,10 @@ project(Light VERSION 1.0.0) set(CMAKE_CXX_STANDARD 14) set(SPIRV_CROSS_ENABLE_TESTS OFF) set(INSTALL_GTEST OFF) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") + +if(NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") +endif() add_subdirectory(Dependencies/ShaderConductor) # <-- this project should not use "cxx_standard 17" # directories diff --git a/Engine/src/Platform/OS/Windows/wWindow.cpp b/Engine/src/Platform/OS/Windows/wWindow.cpp index 6ba9b85..19c2b68 100644 --- a/Engine/src/Platform/OS/Windows/wWindow.cpp +++ b/Engine/src/Platform/OS/Windows/wWindow.cpp @@ -134,88 +134,112 @@ namespace Light { //============================== MOUSE_EVENTS ==============================// /* cursor position */ glfwSetCursorPosCallback(m_Handle, [](GLFWwindow* window, double xpos, double ypos) - { - std::function callback = *(std::function*)glfwGetWindowUserPointer(window); - callback(MouseMovedEvent(xpos, ypos)); - }); + { + std::function callback = *(std::function*)glfwGetWindowUserPointer(window); + + MouseMovedEvent event(xpos, ypos); + callback(event); + }); /* mouse button */ - glfwSetMouseButtonCallback(m_Handle, [](GLFWwindow* window, int button, int action, int mods) - { - std::function callback = *(std::function*)glfwGetWindowUserPointer(window); + glfwSetMouseButtonCallback(m_Handle, [](GLFWwindow* window, int button, int action, int mods) + { + std::function callback = *(std::function*)glfwGetWindowUserPointer(window); - if (action == GLFW_PRESS) - callback(ButtonPressedEvent(button)); - else - callback(ButtonReleasedEvent (button)); - }); + if (action == GLFW_PRESS) + { + ButtonPressedEvent event(button); + callback(event); + } + else if (action == GLFW_RELEASE) + { + ButtonReleasedEvent event(button); + callback(event); + } + }); /* scroll */ glfwSetScrollCallback(m_Handle, [](GLFWwindow* window, double xoffset, double yoffset) - { - std::function callback = *(std::function*)glfwGetWindowUserPointer(window); - callback(WheelScrolledEvent (yoffset)); - }); + { + std::function callback = *(std::function*)glfwGetWindowUserPointer(window); + + WheelScrolledEvent event(yoffset); + callback(event); + }); //============================== MOUSE_EVENTS ==============================// //============================== KEYBOARD_EVENTS ==============================// /* key */ glfwSetKeyCallback(m_Handle, [](GLFWwindow* window, int key, int scancode, int action, int mods) - { - std::function callback = *(std::function*)glfwGetWindowUserPointer(window); - - if (action == GLFW_PRESS) - callback(KeyPressedEvent(key)); - else if (action == GLFW_RELEASE) - callback(KeyReleasedEvent(key)); - else if (action == GLFW_REPEAT) - callback(KeyRepeatEvent(key)); - }); + { + std::function callback = *(std::function*)glfwGetWindowUserPointer(window); + if (action == GLFW_PRESS) + { + KeyPressedEvent event(key); + callback(event); + } + else if (action == GLFW_RELEASE) + { + KeyReleasedEvent event(key); + callback(event); + } + }); /* char */ glfwSetCharCallback(m_Handle, [](GLFWwindow* window, unsigned int character) - { - std::function callback = *(std::function*)glfwGetWindowUserPointer(window); - callback(SetCharEvent(character)); - }); + { + std::function callback = *(std::function*)glfwGetWindowUserPointer(window); - // ImGuiIO& io = ImGui::GetIO(); - // io.AddInputCharacter(c); + SetCharEvent event(character); + callback(event); + }); //============================== KEYBOARD_EVENTS ==============================// //============================== WINDOW_EVENTS ==============================// /* window position */ glfwSetWindowPosCallback(m_Handle, [](GLFWwindow* window, int xpos, int ypos) - { - std::function callback = *(std::function*)glfwGetWindowUserPointer(window); - callback(WindowMovedEvent(xpos, ypos)); - }); + { + std::function callback = *(std::function*)glfwGetWindowUserPointer(window); + WindowMovedEvent event(xpos, ypos); + + callback(event); + }); /* window size */ - glfwSetWindowSizeCallback(m_Handle, [](GLFWwindow* window, int width, int height) - { - std::function callback = *(std::function*)glfwGetWindowUserPointer(window); - callback(WindowResizedEvent(width, height)); - }); + glfwSetWindowSizeCallback(m_Handle, [](GLFWwindow* window, int width, int height) + { + std::function callback = *(std::function*)glfwGetWindowUserPointer(window); + WindowResizedEvent event(width, height); + + callback(event); + }); /* window close */ glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow* window) - { - std::function callback = *(std::function*)glfwGetWindowUserPointer(window); - callback(WindowClosedEvent()); - }); + { + std::function callback = *(std::function*)glfwGetWindowUserPointer(window); + WindowClosedEvent event; + + callback(event); + }); /* window focus */ glfwSetWindowFocusCallback(m_Handle, [](GLFWwindow* window, int focus) - { - std::function callback = *(std::function*)glfwGetWindowUserPointer(window); + { + std::function callback = *(std::function*)glfwGetWindowUserPointer(window); - if(focus == GLFW_TRUE) - callback(WindowGainFocusEvent()); - else - callback(WindowLostFocusEvent()); - }); - //============================== WINDOW_EVENTS ==============================// + if (focus == GLFW_TRUE) + { + WindowGainFocusEvent event; + callback(event); + } + else + { + WindowLostFocusEvent event; + callback(event); + } + }); + //============================== WINDOW_EVENTS ==============================// } } } \ No newline at end of file