Hello to all members of Gamedev.net! :D My name is Patryk and I'm new here.
I started programming in OGL 3.x and encountered a problem with the camera matrix. Here's the code I'm using to calculate the matrix (in Delphi):
{ .: TMainForm.Render :. }
procedure TMainForm.Render;
var
ProjMat, Cam, ModelView: TMatrix;
begin
glViewport(0, 0, ClientWidth, ClientHeight);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
// Projection update
if (ClientHeight <= 0) then
ClientHeight := 1;
ProjMat := MatrixProjection(40.0, ClientWidth / ClientHeight, 0.1, 1000.0);
// Camera transformations
Cam := MatrixTransform(VectorNegate(Camera.Pos), VectorCreate(Camera.Pitch,
Camera.Yaw, 0.0), VectorUniform(1.0));
ModelView := MatrixTransform(VectorCreate(0.0, 0.0, 0.0),
VectorCreate(0.0, TriangleRot, 0.0), VectorUniform(0.5));
ModelView := MatrixMultiply(ModelView, Cam);
ModelView := MatrixMultiply(ModelView, ProjMat);
// Update the shader
glUniformMatrix4fv(glGetUniformLocation(ShaderManager.GLSLPrograms['minimal'].
ProgramHandle, 'mvpmatrix'), 1, ByteBool(GL_FALSE), @ModelView);
// Render the triangle
glBindVertexArray(TriangleVAO);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
end;
And here's the code of my vertex shader:
#version 150
precision highp float;
uniform mat4 mvpmatrix;
in vec3 in_Position;
in vec3 in_Color;
out vec3 ex_Color;
void main(void) {
gl_Position = mvpmatrix * vec4(in_Position, 1.0);
ex_Color = in_Color;
}
The thing is that whenever I change either the
Camera.Pitch or
Camera.Yaw values, the object rotates instead of the camera.
How do I change the code so that I have a Quake-like FPS camera?