5a10a883fb
Currently implemented a 2D camera class that creates an orthographic projection matrix. TODO is implementing a 3D camera class and test program.
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
#include "GLFWInputManager.h"
|
|
|
|
#include "Exception.h"
|
|
|
|
std::map<GLFWwindow*, GLFWInputManager*> GLFWInputManager::s_glfw_windows;
|
|
|
|
GLFWInputManager::~GLFWInputManager()
|
|
{
|
|
s_glfw_windows.erase(m_p_window);
|
|
}
|
|
|
|
void GLFWInputManager::init(GLFWwindow* p_window)
|
|
{
|
|
if (m_p_window != nullptr)
|
|
throw EXCEPTION("GLFWInputManager Already Initialized.");
|
|
m_p_window = p_window;
|
|
s_glfw_windows.insert(std::map<GLFWwindow*, GLFWInputManager*>::value_type(m_p_window, this));
|
|
}
|
|
|
|
void GLFWInputManager::key_callback(GLFWwindow* p_window, int key, int scancode, int action, int mods)
|
|
{
|
|
std::map<GLFWwindow*, GLFWInputManager*>::iterator iter = s_glfw_windows.find(p_window);
|
|
if (iter == s_glfw_windows.end())
|
|
return; // Ignore Unknown Windows
|
|
GLFWInputManager& input_manager = *iter->second;
|
|
if (action == GLFW_PRESS)
|
|
input_manager.key_down(key);
|
|
else if (action == GLFW_RELEASE)
|
|
input_manager.key_up(key);
|
|
else if (action == GLFW_REPEAT) { /* Ignored */}
|
|
else
|
|
throw Exception("Invalid GLFW Key Action: " + std::to_string(action) + " (" + std::to_string(scancode) + ")", "class GLFWInputManager");
|
|
|
|
}
|