Fixed Windows

This commit is contained in:
Light 2021-09-24 17:20:19 +03:30
parent f0e127dbd0
commit b24c94a718
2 changed files with 81 additions and 54 deletions

View file

@ -5,7 +5,10 @@ project(Light VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(SPIRV_CROSS_ENABLE_TESTS OFF) set(SPIRV_CROSS_ENABLE_TESTS OFF)
set(INSTALL_GTEST OFF) set(INSTALL_GTEST OFF)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error")
endif()
add_subdirectory(Dependencies/ShaderConductor) # <-- this project should not use "cxx_standard 17" add_subdirectory(Dependencies/ShaderConductor) # <-- this project should not use "cxx_standard 17"
# directories # directories

View file

@ -136,7 +136,9 @@ namespace Light {
glfwSetCursorPosCallback(m_Handle, [](GLFWwindow* window, double xpos, double ypos) glfwSetCursorPosCallback(m_Handle, [](GLFWwindow* window, double xpos, double ypos)
{ {
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
callback(MouseMovedEvent(xpos, ypos));
MouseMovedEvent event(xpos, ypos);
callback(event);
}); });
/* mouse button */ /* mouse button */
@ -145,16 +147,24 @@ namespace Light {
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
if (action == GLFW_PRESS) if (action == GLFW_PRESS)
callback(ButtonPressedEvent(button)); {
else ButtonPressedEvent event(button);
callback(ButtonReleasedEvent (button)); callback(event);
}
else if (action == GLFW_RELEASE)
{
ButtonReleasedEvent event(button);
callback(event);
}
}); });
/* scroll */ /* scroll */
glfwSetScrollCallback(m_Handle, [](GLFWwindow* window, double xoffset, double yoffset) glfwSetScrollCallback(m_Handle, [](GLFWwindow* window, double xoffset, double yoffset)
{ {
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
callback(WheelScrolledEvent (yoffset));
WheelScrolledEvent event(yoffset);
callback(event);
}); });
//============================== MOUSE_EVENTS ==============================// //============================== MOUSE_EVENTS ==============================//
@ -165,22 +175,24 @@ namespace Light {
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
if (action == GLFW_PRESS) if (action == GLFW_PRESS)
callback(KeyPressedEvent(key)); {
KeyPressedEvent event(key);
callback(event);
}
else if (action == GLFW_RELEASE) else if (action == GLFW_RELEASE)
callback(KeyReleasedEvent(key)); {
else if (action == GLFW_REPEAT) KeyReleasedEvent event(key);
callback(KeyRepeatEvent(key)); callback(event);
}
}); });
/* char */ /* char */
glfwSetCharCallback(m_Handle, [](GLFWwindow* window, unsigned int character) glfwSetCharCallback(m_Handle, [](GLFWwindow* window, unsigned int character)
{ {
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
callback(SetCharEvent(character));
});
// ImGuiIO& io = ImGui::GetIO(); SetCharEvent event(character);
// io.AddInputCharacter(c); callback(event);
});
//============================== KEYBOARD_EVENTS ==============================// //============================== KEYBOARD_EVENTS ==============================//
@ -189,21 +201,27 @@ namespace Light {
glfwSetWindowPosCallback(m_Handle, [](GLFWwindow* window, int xpos, int ypos) glfwSetWindowPosCallback(m_Handle, [](GLFWwindow* window, int xpos, int ypos)
{ {
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
callback(WindowMovedEvent(xpos, ypos)); WindowMovedEvent event(xpos, ypos);
callback(event);
}); });
/* window size */ /* window size */
glfwSetWindowSizeCallback(m_Handle, [](GLFWwindow* window, int width, int height) glfwSetWindowSizeCallback(m_Handle, [](GLFWwindow* window, int width, int height)
{ {
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
callback(WindowResizedEvent(width, height)); WindowResizedEvent event(width, height);
callback(event);
}); });
/* window close */ /* window close */
glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow* window) glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow* window)
{ {
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
callback(WindowClosedEvent()); WindowClosedEvent event;
callback(event);
}); });
/* window focus */ /* window focus */
@ -212,10 +230,16 @@ namespace Light {
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
if (focus == GLFW_TRUE) if (focus == GLFW_TRUE)
callback(WindowGainFocusEvent()); {
WindowGainFocusEvent event;
callback(event);
}
else else
callback(WindowLostFocusEvent()); {
WindowLostFocusEvent event;
callback(event);
}
}); });
//============================== WINDOW_EVENTS ==============================// //============================== WINDOW_EVENTS ==============================// }
} }
} }