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,21 +109,19 @@ static void defaultKeyCallback(GLFWwindow *window, int key, int scancode, int ac
}
static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *data) {
static bool firstMouse = true;
static double lastX = 0, lastY = 0;
if(firstMouse) {
lastX = x;
lastY = y;
firstMouse = false;
}
switch(Input::getCursorMode()) {
case GLFWCursorMode::CAPTURE:
{
static bool firstMouse = true;
static double lastX = 0, lastY = 0;
if(firstMouse) {
lastX = x;
lastY = y;
firstMouse = false;
}
float xoff = lastX - x;
float yoff = lastY - y;
lastX = x;
lastY = y;
xoff *= 0.1f;
yoff *= 0.1f;
@ -139,6 +137,9 @@ static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *d
break;
}
}
lastX = x;
lastY = y;
}
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(GenericFunction<Args..., void *> function): function(function), data(nullptr) {};
GenericCallable(GenericFunction<Args..., void *> function, void *data): function(function), data(data) {}
void operator()(Args... args) {