fix bugs in fisheye rendering

This commit is contained in:
Emil Axelsson
2016-02-08 14:33:19 +01:00
parent f8e9a158b3
commit 781ca62742
3 changed files with 19 additions and 4 deletions

View File

@@ -232,6 +232,10 @@ bool RenderableModelProjection::initialize() {
bool RenderableModelProjection::auxiliaryRendertarget() {
bool completeSuccess = true;
// set FBO to texture to project to
GLint defaultFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO);
glGenFramebuffers(1, &_fboID);
glBindFramebuffer(GL_FRAMEBUFFER, _fboID);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, *_texture, 0);
@@ -240,7 +244,7 @@ bool RenderableModelProjection::auxiliaryRendertarget() {
if (status != GL_FRAMEBUFFER_COMPLETE)
completeSuccess &= false;
// switch back to window-system-provided framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
int vertexSize = sizeof(modelgeometry::ModelGeometry::Vertex);

View File

@@ -271,6 +271,10 @@ bool RenderablePlanetProjection::initialize() {
bool RenderablePlanetProjection::auxiliaryRendertarget(){
bool completeSuccess = true;
if (!_texture) return false;
GLint defaultFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO);
// setup FBO
glGenFramebuffers(1, &_fboID);
glBindFramebuffer(GL_FRAMEBUFFER, _fboID);
@@ -280,7 +284,7 @@ bool RenderablePlanetProjection::auxiliaryRendertarget(){
if (status != GL_FRAMEBUFFER_COMPLETE)
completeSuccess &= false;
// switch back to window-system-provided framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
// SCREEN-QUAD
const GLfloat size = 1.0f;
@@ -384,7 +388,7 @@ void RenderablePlanetProjection::imageProjectGPU(){
glBindVertexArray(_quad);
glDrawArrays(GL_TRIANGLES, 0, 6);
_fboProgramObject->deactivate();
glDisable(GL_BLEND);
//glDisable(GL_BLEND);
//bind back to default
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);

View File

@@ -272,7 +272,14 @@ bool RenderEngine::initializeGL() {
//#endif
const glm::vec3 eyePosition = sgct_core::ClusterManager::instance()->getDefaultUserPtr()->getPos();
// get viewdirection, stores the direction in the camera, used for culling
const glm::vec3 viewdir = glm::normalize(eyePosition - center);
glm::vec3 viewdir = eyePosition - center;
if (viewdir == glm::vec3(0)) {
viewdir = glm::vec3(0, 0, 1);
} else {
viewdir = glm::normalize(viewdir);
}
_mainCamera->setCameraDirection(-viewdir);
_mainCamera->setLookUpVector(glm::vec3(0.0, 1.0, 0.0));