Fixed Windows
This commit is contained in:
parent
f0e127dbd0
commit
b24c94a718
2 changed files with 81 additions and 54 deletions
|
@ -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
|
||||
|
|
|
@ -134,88 +134,112 @@ namespace Light {
|
|||
//============================== MOUSE_EVENTS ==============================//
|
||||
/* cursor position */
|
||||
glfwSetCursorPosCallback(m_Handle, [](GLFWwindow* window, double xpos, double ypos)
|
||||
{
|
||||
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
|
||||
callback(MouseMovedEvent(xpos, ypos));
|
||||
});
|
||||
{
|
||||
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
|
||||
|
||||
MouseMovedEvent event(xpos, ypos);
|
||||
callback(event);
|
||||
});
|
||||
|
||||
/* mouse button */
|
||||
glfwSetMouseButtonCallback(m_Handle, [](GLFWwindow* window, int button, int action, int mods)
|
||||
{
|
||||
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
|
||||
glfwSetMouseButtonCallback(m_Handle, [](GLFWwindow* window, int button, int action, int mods)
|
||||
{
|
||||
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)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<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
|
||||
callback(WheelScrolledEvent (yoffset));
|
||||
});
|
||||
{
|
||||
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)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<void(Event&)> callback = *(std::function<void(Event&)>*)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<void(Event&)> callback = *(std::function<void(Event&)>*)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<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
|
||||
callback(SetCharEvent(character));
|
||||
});
|
||||
{
|
||||
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)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<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
|
||||
callback(WindowMovedEvent(xpos, ypos));
|
||||
});
|
||||
{
|
||||
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
|
||||
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));
|
||||
});
|
||||
glfwSetWindowSizeCallback(m_Handle, [](GLFWwindow* window, int width, int height)
|
||||
{
|
||||
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
|
||||
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());
|
||||
});
|
||||
{
|
||||
std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window);
|
||||
WindowClosedEvent event;
|
||||
|
||||
callback(event);
|
||||
});
|
||||
|
||||
/* window focus */
|
||||
glfwSetWindowFocusCallback(m_Handle, [](GLFWwindow* window, int focus)
|
||||
{
|
||||
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)
|
||||
callback(WindowGainFocusEvent());
|
||||
else
|
||||
callback(WindowLostFocusEvent());
|
||||
});
|
||||
//============================== WINDOW_EVENTS ==============================//
|
||||
if (focus == GLFW_TRUE)
|
||||
{
|
||||
WindowGainFocusEvent event;
|
||||
callback(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowLostFocusEvent event;
|
||||
callback(event);
|
||||
}
|
||||
});
|
||||
//============================== WINDOW_EVENTS ==============================// }
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue