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(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

View file

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