Fix cursor pos, Add convenience constructor

This commit is contained in:
MrLetsplay 2023-09-13 17:14:17 +02:00
parent d30f505699
commit d47eb8c943
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
2 changed files with 13 additions and 10 deletions

View File

@ -109,9 +109,6 @@ static void defaultKeyCallback(GLFWwindow *window, int key, int scancode, int ac
} }
static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *data) { static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *data) {
switch(Input::getCursorMode()) {
case GLFWCursorMode::CAPTURE:
{
static bool firstMouse = true; static bool firstMouse = true;
static double lastX = 0, lastY = 0; static double lastX = 0, lastY = 0;
if(firstMouse) { if(firstMouse) {
@ -120,10 +117,11 @@ static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *d
firstMouse = false; firstMouse = false;
} }
switch(Input::getCursorMode()) {
case GLFWCursorMode::CAPTURE:
{
float xoff = lastX - x; float xoff = lastX - x;
float yoff = lastY - y; float yoff = lastY - y;
lastX = x;
lastY = y;
xoff *= 0.1f; xoff *= 0.1f;
yoff *= 0.1f; yoff *= 0.1f;
@ -139,6 +137,9 @@ static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *d
break; break;
} }
} }
lastX = x;
lastY = y;
} }
static void defaultMouseButtonCallback(GLFWwindow* window, int button, int action, int mods, void *data) { static void defaultMouseButtonCallback(GLFWwindow* window, int button, int action, int mods, void *data) {

View File

@ -18,6 +18,8 @@ struct GenericCallable {
GenericCallable(): function(nullptr), data(nullptr) {} GenericCallable(): function(nullptr), data(nullptr) {}
GenericCallable(GenericFunction<Args..., void *> function): function(function), data(nullptr) {};
GenericCallable(GenericFunction<Args..., void *> function, void *data): function(function), data(data) {} GenericCallable(GenericFunction<Args..., void *> function, void *data): function(function), data(data) {}
void operator()(Args... args) { void operator()(Args... args) {