File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,6 @@ float initialFoV = 45.0f;
3333float speed = 3 .0f ; // 3 units / second
3434float mouseSpeed = 0 .005f ;
3535
36-
37-
3836void 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);
You can’t perform that action at this time.
0 commit comments