From 44f2bd953d9fa6df63b9bf8fa1a1318b9f365e26 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 15 Dec 2014 11:22:32 +0100 Subject: [PATCH] Replacing buildFrustum with standard glm call. --- graphics.cc | 15 ++------------- graphics.hh | 2 -- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/graphics.cc b/graphics.cc index 9e944ee..390713a 100644 --- a/graphics.cc +++ b/graphics.cc @@ -97,7 +97,7 @@ void Graphics::render() depthShader->use(); // render depth textures for point lights glViewport(0, 0, cube_size, cube_size); - glm::mat4 depthProjectionMatrix_pointlights = glm::perspective(45.0f, 0.1f, farPlane, (float)cube_size/(float)cube_size); + glm::mat4 depthProjectionMatrix_pointlights = glm::perspective(1.571f, (float)cube_size/(float)cube_size, 0.1f, farPlane); glm::vec3 looking_directions[6] = {glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(-1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, 0.0f, -1.0f)}; @@ -159,7 +159,7 @@ void Graphics::render() lightingShader->use(); //set view and projection matrix - glm::mat4 lightingViewProjectionMatrix = buildFrustum(75.0f, 0.1f, farPlane, (float)windowSize.x/(float)windowSize.y) * buildViewMatrix(level); + glm::mat4 lightingViewProjectionMatrix = glm::perspective(1.571f, (float)windowSize.x/(float)windowSize.y, 0.1f, farPlane) * buildViewMatrix(level); lightingShader->setUniform("lightingViewProjectionMatrix", lightingViewProjectionMatrix); //set lighting parameters @@ -238,17 +238,6 @@ void Graphics::resize(glm::uvec2 windowSize) { depthTexture_far->resize(glm::vec2(windowSize.x, windowSize.y)); } -glm::mat4 Graphics::buildFrustum( float phiInDegree, float _near, float _far, float aspectRatio) { - - float phiHalfInRadians = 0.5*phiInDegree * (M_PI/180.0); - float top = _near * tan( phiHalfInRadians ); - float bottom = -top; - float left = bottom * aspectRatio; - float right = -left; - - return glm::frustum(left, right, bottom, top, _near, _far); -} - glm::mat4 Graphics::buildViewMatrix(Level* level) { //construct lookAt (cameraPosition = cameraCenter + cameraVector return glm::lookAt((level->getCameraCenter()->getPosition() + level->getCamera()->getVector()), diff --git a/graphics.hh b/graphics.hh index 8dd1018..416f5ce 100644 --- a/graphics.hh +++ b/graphics.hh @@ -14,8 +14,6 @@ class Graphics { Graphics(); void init(Level* level); void render(); - // to build the projection matrix: - glm::mat4 buildFrustum( float phiInDegree, float near, float far, float aspectRatio); glm::mat4 buildViewMatrix(Level* level); glm::uvec2 getWindowSize(); bool createWindow();