16 ErrorCallback* ErrorCallback::current =
nullptr;
24 if (callback !=
nullptr) {
29 void ErrorCallback::dispatch(
int error,
const char* description) {
32 current->
invoke(error,
string(description));
36 ErrorCallback::ErrorCallback(
void) {
40 ErrorCallback::~ErrorCallback(
void) {
42 if (ErrorCallback::current ==
this) {
43 ErrorCallback::current =
nullptr;
48 void ErrorCallback::invoke(
int error, std::string description) {
49 Logger::logError(
"GLFW error " + to_string(error) +
": " + description);
60 if (callback !=
nullptr) {
65 void KeyCallback::dispatch(GLFWwindow* window,
int key,
int scancode,
int action,
int mods) {
68 current->
invoke(window, static_cast<Key> (key), scancode, static_cast<Action> (action), static_cast<Modifier> (mods));
72 KeyCallback::KeyCallback(
void) {
76 KeyCallback::~KeyCallback(
void) {
78 if (KeyCallback::current ==
this) {
79 KeyCallback::current =
nullptr;
84 void KeyCallback::invoke(GLFWwindow* window,
Key key,
int scancode,
Action action,
Modifier mods) {
86 Event::addEvent(event);
97 if (callback !=
nullptr) {
102 void MouseButtonCallback::dispatch(GLFWwindow* window,
int button,
int action,
int mods) {
105 current->
invoke(window, static_cast<MouseButton> (button), static_cast<Action> (action), static_cast<Modifier> (mods));
109 MouseButtonCallback::MouseButtonCallback(
void) {
113 MouseButtonCallback::~MouseButtonCallback(
void) {
115 if (MouseButtonCallback::current ==
this) {
116 MouseButtonCallback::current =
nullptr;
123 Event::addEvent(event);
virtual void invoke(int error, std::string description)
This function gets called whenever a GLFW error occurs.
MouseButton
This enum wraps the GLFW mouse buttons.
Key
This enum wraps the GLFW keys.
This class wraps a GLFW error callback.
Modifier
This enum wraps the GLFW modifier bits.
Generic namespace for the SimpleGL framework.
This class wraps a GLFW key callback.
Action
This enum wraps the GLFW actions.
virtual void invoke(GLFWwindow *window, Key key, int scancode, Action action, Modifier mods)
This function gets called whenever a key is pressed or released.
This class defines a key event, created by the KeyCallback.