updating renderer work done
This commit is contained in:
@@ -3,3 +3,34 @@
|
||||
//
|
||||
|
||||
#include "camera.h"
|
||||
|
||||
Camera l_camera = {
|
||||
.Position = { 0.0f, 0.0f, 0.0f },
|
||||
.Orientation = { 0.0f, 0.0f, -1.0f },
|
||||
.Up = { 0.0f, 1.0f, 0.0f }
|
||||
};
|
||||
|
||||
void matrix(float FOVdeg, float nearPlane, float farPlane, Shader* shader_instance, const char* uniform) {
|
||||
mat4 view, projection;
|
||||
glm_mat4_identity(view);
|
||||
glm_mat4_identity(projection);
|
||||
|
||||
// store the result of the vector addition
|
||||
vec3 target;
|
||||
|
||||
// cglm function to perform vector addition
|
||||
glm_vec3_add(l_camera.Position, l_camera.Orientation, target);
|
||||
|
||||
mat4 target_2;
|
||||
|
||||
glm_mat4_mul(projection[0], view[0], target_2);
|
||||
|
||||
// now we can use the addition of the two vec3's in the glm_lookat() function
|
||||
glm_lookat(l_camera.Position, target, l_camera.Up, view);
|
||||
|
||||
glm_perspective(glm_rad(FOVdeg), (float)(l_camera.width / l_camera.height), nearPlane, farPlane, projection);
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shader_instance->ID, uniform), 1, GL_FALSE, target_2);
|
||||
}
|
||||
|
||||
void inputs(SDL_Window* window);
|
||||
Reference in New Issue
Block a user