File tree 1 file changed +8
-2
lines changed
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;
33
33
float speed = 3 .0f ; // 3 units / second
34
34
float mouseSpeed = 0 .005f ;
35
35
36
-
37
-
38
36
void computeMatricesFromInputs (){
39
37
40
38
// glfwGetTime is called only once, the first time this function is called
@@ -44,6 +42,14 @@ void computeMatricesFromInputs(){
44
42
double currentTime = glfwGetTime ();
45
43
float deltaTime = float (currentTime - lastTime);
46
44
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
+
47
53
// Get mouse position
48
54
double xpos, ypos;
49
55
glfwGetCursorPos (window, &xpos, &ypos);
You can’t perform that action at this time.
0 commit comments