Skip to content

Commit ebfd317

Browse files
committed
Fix camera direction bug
1 parent 345792f commit ebfd317

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

common/controls.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ float initialFoV = 45.0f;
3333
float speed = 3.0f; // 3 units / second
3434
float mouseSpeed = 0.005f;
3535

36-
37-
3836
void computeMatricesFromInputs(){
3937

4038
// glfwGetTime is called only once, the first time this function is called
@@ -44,6 +42,14 @@ void computeMatricesFromInputs(){
4442
double currentTime = glfwGetTime();
4543
float deltaTime = float(currentTime - lastTime);
4644

45+
// First time this function is called, the cursor position is reset since
46+
// an unintended movement will otherwise register on the first frame
47+
static bool first_frame = true;
48+
if (first_frame){
49+
glfwSetCursorPos(window, 1024/2, 768/2);
50+
first_frame = false;
51+
}
52+
4753
// Get mouse position
4854
double xpos, ypos;
4955
glfwGetCursorPos(window, &xpos, &ypos);

0 commit comments

Comments
 (0)