Skip to content

Commit

Permalink
Fix camera direction bug
Browse files Browse the repository at this point in the history
  • Loading branch information
n-l-i committed Dec 4, 2022
1 parent 345792f commit ebfd317
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions common/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ float initialFoV = 45.0f;
float speed = 3.0f; // 3 units / second
float mouseSpeed = 0.005f;



void computeMatricesFromInputs(){

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

// First time this function is called, the cursor position is reset since
// an unintended movement will otherwise register on the first frame
static bool first_frame = true;
if (first_frame){
glfwSetCursorPos(window, 1024/2, 768/2);
first_frame = false;
}

// Get mouse position
double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos);
Expand Down

0 comments on commit ebfd317

Please sign in to comment.