callback calls the callback that's called by the callback calling callback
This commit is contained in:
@@ -4,7 +4,18 @@
|
||||
|
||||
using namespace inferno;
|
||||
|
||||
Window::Window(std::string title, int width, int height)
|
||||
Window::Window()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
shutdownImGui();
|
||||
shutdownGLFW();
|
||||
}
|
||||
|
||||
void Window::init(std::string title, int width, int height)
|
||||
{
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
@@ -16,12 +27,6 @@ Window::Window(std::string title, int width, int height)
|
||||
setupImGui();
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
shutdownImGui();
|
||||
shutdownGLFW();
|
||||
}
|
||||
|
||||
void Window::setTitle(std::string title)
|
||||
{
|
||||
glfwSetWindowTitle(window, title.c_str());
|
||||
@@ -50,6 +55,26 @@ void Window::getPos(int& x, int& y)
|
||||
glfwGetWindowPos(window, &x, &y);
|
||||
}
|
||||
|
||||
void Window::setKeyCallback(KeyCallback callback)
|
||||
{
|
||||
mKeyCallback = callback;
|
||||
}
|
||||
|
||||
void Window::setMouseCallback(MouseCallback callback)
|
||||
{
|
||||
mMouseCallback = callback;
|
||||
}
|
||||
|
||||
KeyCallback Window::getKeyCallback()
|
||||
{
|
||||
return mKeyCallback;
|
||||
}
|
||||
|
||||
MouseCallback Window::getMouseCallback()
|
||||
{
|
||||
return mMouseCallback;
|
||||
}
|
||||
|
||||
bool Window::newFrame()
|
||||
{
|
||||
glfwPollEvents();
|
||||
@@ -153,12 +178,18 @@ void Window::shutdownGLFW()
|
||||
|
||||
void Window::glfwKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
|
||||
if (Window::GetInstance().getKeyCallback() != nullptr)
|
||||
{
|
||||
Window::GetInstance().getKeyCallback()(key, scancode, action, mods);
|
||||
}
|
||||
}
|
||||
|
||||
void Window::glfwMouseCallback(GLFWwindow* window, double xpos, double ypos)
|
||||
{
|
||||
|
||||
if (Window::GetInstance().getMouseCallback() != nullptr)
|
||||
{
|
||||
Window::GetInstance().getMouseCallback()(xpos, ypos);
|
||||
}
|
||||
}
|
||||
|
||||
void Window::glfwErrorCallback(int error, const char* description) {
|
||||
|
||||
Reference in New Issue
Block a user