Skip to content
Snippets Groups Projects
Select Git revision
  • main
  • master
2 results

APIController.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    camera.cpp 895 B
    #include"Camera.h"
    
    
    
    Camera::Camera(int width, int height, glm::vec3 position) {
    	Camera::width = width;
    	Camera::height = height;
    	Camera::Position = position;
    }
    
    
    
    void Camera::Matrix(float FOVdeg, float nearPlane, float farPlane, Shader& shader, const char* uniform, glm::mat4 transform) {
    	// Initializes matrices since otherwise they will be the null matrix
    	glm::mat4 view = glm::mat4(1.0f);
    	glm::mat4 projection = glm::mat4(1.0f);
    	// Makes camera look in the right direction from the right position
    	view = glm::lookAt(Position, Position + Orientation, Up);
    	// Adds perspective to the scene
    	projection = glm::perspective(glm::radians(FOVdeg), (float)width / height, nearPlane, farPlane);
    	// Exports the camera matrix and uniform matrix to the Vertex Shader
    	glUniformMatrix4fv(glGetUniformLocation(shader.ID, uniform), 1, GL_FALSE, glm::value_ptr(projection * view * transform));
    
    }