fixed issues in deferred pipeline and trackballcamera

This commit is contained in:
Anselme FRANÇOIS 2016-06-24 18:54:02 +02:00
parent 01973cea0b
commit db8d271d07
4 changed files with 20 additions and 12 deletions

View File

@ -1,13 +1,13 @@
#include <sparrowrenderer.h> #include "sparrowrenderer.h"
#include "deferredpipeline.h" #include "deferredpipeline.h"
#include <texture.h> #include "texture.h"
#include <scene.h> #include "scene.h"
#include <mesh.h> #include "mesh.h"
#include <shader.h> #include "shader.h"
#include <glm/ext.hpp> #include <glm/ext.hpp>
#include <shadersource.h> #include "shadersource.h"
#include <phongmaterial.h> #include "phongmaterial.h"
#include <camera.h> #include "camera.h"
#include <resource.h> #include <resource.h>
RESOURCE_PACK(shaders) RESOURCE_PACK(shaders)
@ -195,7 +195,7 @@ void DeferredPipeline::resizeGL(int w, int h)
m_lightingBuffer = new LightingBuffer(w, h); m_lightingBuffer = new LightingBuffer(w, h);
} }
void setSources(ShaderSource *gBufferSource, ShaderSource *lightingSource, Shader *postEffectsShader) void DeferredPipeline::setSources(ShaderSource *gBufferSource, ShaderSource *lightingSource, Shader *postEffectsShader)
{ {
if(m_gBufferSource != NULL) if(m_gBufferSource != NULL)
delete m_gBufferSource; delete m_gBufferSource;

View File

@ -1,8 +1,8 @@
#ifndef DEFERREDPIPELINE_H #ifndef DEFERREDPIPELINE_H
#define DEFERREDPIPELINE_H #define DEFERREDPIPELINE_H
#include <pipeline.h> #include "pipeline.h"
#include <framebuffer.h> #include "framebuffer.h"
#include <unordered_map> #include <unordered_map>
class Shader; class Shader;

View File

@ -63,3 +63,10 @@ void TrackBallCamera::zoom(int nbUnits)
} }
computeView(); computeView();
} }
glm::vec3 TrackBallCamera::getDefaultPxInfo()
{
glm::vec4 screenPos(m_center, 1);
screenPos = (m_projection * m_view) * screenPos;
return glm::vec3(m_dist/m_far, 1/screenPos.w, 0);
}

View File

@ -16,12 +16,13 @@ private:
void computeView(); void computeView();
public: public:
TrackBallCamera(float myFov = 70.f, float myNear = 0.1f, float myFar = 100.f); TrackBallCamera(float myFov = 70.f, float myNear = 0.1f, float myFar = 1000.f);
void rotateCamera(float dx, float dy); void rotateCamera(float dx, float dy);
void moveCamera(float dx, float dy); void moveCamera(float dx, float dy);
void zoom(int nbScrolls); void zoom(int nbScrolls);
void reset(); void reset();
glm::vec3 getDefaultPxInfo();
}; };
#endif // TRACKBALLCAMERA_H #endif // TRACKBALLCAMERA_H