Basic concept working

This commit is contained in:
4VRDriver
2020-09-12 21:21:36 +02:00
parent 712c2655cf
commit 917c0db0d0
9 changed files with 84 additions and 20 deletions

View File

@@ -4,10 +4,10 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/ext/matrix_transform.hpp>
Camera::Camera(float fov, int width, int height) {
Camera::Camera(float fov, float aspectRatio) {
this->fov = fov;
viewMatrix = glm::mat4(1.0f);
updateAspectRatio(width, height);
updateAspectRatio(aspectRatio);
updateVPM();
}
@@ -15,9 +15,9 @@ void Camera::updateVPM() {
viewProjectionMatrix = projectionMatrix * viewMatrix;
}
void Camera::updateAspectRatio(int width, int height) {
void Camera::updateAspectRatio(float aspectRatio) {
//projectionMatrix = glm::ortho(-2.0f, 2.0f, -2.0f, 2.0f, -10.f, 100.0f);
projectionMatrix = glm::perspective(fov/2.0f, (float)width / (float)height, 0.1f, 1000.0f);
projectionMatrix = glm::perspective(fov/2.0f, aspectRatio, 0.1f, 1000.0f);
updateVPM();
}