Fix cursor pos, Add convenience constructor
This commit is contained in:
parent
d30f505699
commit
d47eb8c943
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user