@Dark_Photon

Hi,

here is a link to the code in my GitHub repo.

Basically what I do is this:

- Calculating new camera resulting quaternion using cglm in a separate thread function

```
void *fake_headtracking(void *c_ptr){
my_camera_t *c = c_ptr;
versor rollQuat, pitchQuat, yawQuat;
glm_quat_identity(rollQuat);
glm_quat_identity(yawQuat);
glm_quat_identity(pitchQuat);
float yaw, pitch, roll;
yaw = 180;
pitch = 0;
roll = 0;
float yawd = 1;
float pitchd = 1;
float rolld = -1;
while(!EXIT){
// yaw += yawd;
// pitch += pitchd;
roll += rolld;
if (roll >= 50 || roll <=-50) rolld = -rolld;
if (pitch >= 50 || pitch <=-50) pitchd = -pitchd;
if (yaw >= 50 || yaw <=-50) yawd = -yawd;
glm_quatv(pitchQuat, my_radians(pitch), (vec3){1.0f, 0.0f, 0.0f});
glm_quatv(yawQuat, my_radians(yaw), (vec3){0.0f, 1.0f, 0.0f});
glm_quatv(rollQuat, my_radians(roll), (vec3){0.0f, 0.0f, 1.0f});
glm_quat_mul(yawQuat, pitchQuat, c->resultQuat);
glm_quat_mul(c->resultQuat, rollQuat, c->resultQuat);
usleep(15000);
}
return NULL;
}
```

This is what I do in render loop:

```
// generate projection matrix
glm_perspective(cam.fov, (GLfloat)SCR_WIDTH / (GLfloat)SCR_HEIGHT, 0.01f, 100.0f, proj); // zoom
// generate view matrix
glm_quat_look(cam.cameraPos, cam.resultQuat, view);
// send MVP matrices to vertex shader
my_send_shander_4x4_matrix(modelLoc, 1, &model[0][0]);
my_send_shander_4x4_matrix(viewLoc, 1, &view[0][0]);
my_send_shander_4x4_matrix(projLoc, 1, &proj[0][0]);
my_bind_texture(textures[0]);
my_bind_vertex_object_and_draw_it(VAOs[0], GL_TRIANGLES, myWin.numTriangles);
```

And this is what my vertex shader looks like:

```
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoord;
out vec2 TexCoord;
uniform mat4 model;
uniform mat4 view;
uniform mat4 proj;
void main(){
gl_Position = proj*view*model*vec4(aPos.x, aPos.y, aPos.z , 1.0);
TexCoord = vec2(1.0 - aTexCoord.x, aTexCoord.y);
}
```

I tried setting the window resolution to 720x720 (making a square), but the same thing happen.

Also, I’m pretty sure that the problem is not related to multithreading…