# OpenTK OpenGL wierd camera look

I am trying to implement a simple camera mouse look.

if (Input.GetInstance().GetMouseKey(MouseButton.Middle))
{
Vector2 d = Input.GetInstance().getMouseDelta() * 0.001f;
}


Here is the camera matrix:

cameraMatrix = Matrix4.LookAt(myEntity.transform.Position, myEntity.transform.Position + myEntity.transform.GetForward(), myEntity.transform.GetUp());


I also tried to create camera matrix like this, but the results were the same:

Matrix4 t = Matrix4.CreateTranslation(myEntity.transform.Position);
Matrix4 r = myEntity.transform.RotationMatrix;
cameraMatrix = t * r;


Here is the rotation matrix of transform:

var x = Matrix4.CreateRotationX(rotation.X);
var y = Matrix4.CreateRotationY(rotation.Y);
var z = Matrix4.CreateRotationZ(rotation.Z);
rotationMatrix = x * y * z;


public void AddRotation(Vector3 rotation)
{
if (rotation == Vector3.Zero) return;
this.rotation += rotation;
myEntity.ObserverOnRotationChanged();
}


Get forward method of transform:

public Vector3 GetForward()
{
return new Vector3(RotationMatrix * new Vector4(0.0f,0.0f,1.0f,0.0f));
//or just extract third column from matrix
}


#version 330

uniform mat4 transformMat;
uniform mat4 cameraMat;
uniform mat4 projectionMat;

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 normal;
layout (location = 2) in vec2 uv;

void main(){
gl_Position = projectionMat * cameraMat * transformMat * vec4(position, 1.0);
}


It rotates the camera around global x axis instead of local x when i look at triangle from the side. Thanks.

var x = Matrix4.CreateRotationX(rotation.X);