I've been trying to set up a camera in OpenGL for a few days now, but I just can't get it working properly. As the eye.X or eye.Y value increases/decreases, instead of "looking arround", the camera(I know there is no such thing as a camera...) moves away/gets closer to the drawings!
I hope following information can help you.(I also uploaded a Video, which is showing the error): https://www.youtube.com/watch?v=OlD5X0EzkUw
These are my ModelView calculations on OnUpdateFrame.
_worldPosition = Matrix4.CreateTranslation(_worldX, _worldY, _worldZ);
_cameraMatrix = Matrix4.LookAt(eye.X, eye.Y, eye.Z, center.X, center.Y, center.Z, up.X, up.Y, up.Z);
_modelViewMatrix = _worldPosition * _cameraMatrix;
Here, I adjust the values with OnMouseMove function:
if (_mouseDown)
{
_mousePos.X = 2.0f * Mouse.X / Width - 1;
_mousePos.Y = 2.0f * Mouse.Y / Width - 1;
_mouseDeltaY = (_mousePosOld.Y - _mousePos.Y) / 10;
_mouseDeltaX = (_mousePosOld.X - _mousePos.X) / 10;
eye.X -= _mouseDeltaX;
eye.Y -= _mouseDeltaY;
}
And finally my Vertex shader:
#version 440 core
layout (location = 0) in vec4 position;
layout(location = 1) in vec4 color;
layout(location = 2) uniform mat4 projectionMatrix;
layout (location = 3) uniform mat4 modelViewMatrix;
out vec4 vs_color;
void main(void)
{
gl_Position = projectionMatrix * modelViewMatrix * position;
vs_color = color;
}