fixed renderer clearing last used FBO instead of clearing screen

This commit is contained in:
Anselme 2015-12-16 01:10:57 +01:00
parent 2760f0c38f
commit afcd38fcbe
2 changed files with 11 additions and 3 deletions

View File

@ -62,6 +62,12 @@ bool Light::isDirectionnal()
void Light::initShadowMap(int resWidth, int resHeight, glm::vec3 dim)
{
viewMatrix = glm::lookAt(position, position+direction, glm::vec3(0, 1, 0));
if(type == DIRECTIONNAL)
projectionMatrix = glm::ortho(-dim.x/2, dim.x/2, -dim.y/2, dim.y/2, -dim.z/2, dim.z/2);
else
; // TODO : glm::projection
shadowCaster = true;
shadowMap = new FrameBuffer();
// Depth buffer
@ -81,8 +87,6 @@ void Light::initShadowMap(int resWidth, int resHeight, glm::vec3 dim)
void Light::generateShadowMap(Scene* scene)
{
viewMatrix = glm::lookAt(position, position+direction, glm::vec3(0, 1, 0));
shadowMap->bindFBO();
glAssert(glEnable(GL_DEPTH_TEST));
for(SceneIterator<PhongEntity*>* entityIt = scene->getGeometry();
@ -96,7 +100,7 @@ void Light::generateShadowMap(Scene* scene)
for(int j=0; j<entity->getMesh()->indiceGroups.size(); ++j)
{
Material* mat = entity->getMesh()->indiceGroups[j].material;
if(mat->getFlags() & ALPHA_MASK)
if(mat->getFlags() & ALPHA_MASK_FLAG)
{
PhongMaterial* pmat = (PhongMaterial*)mat;
shaders[1]->bind();

View File

@ -1,8 +1,11 @@
#include <glew/glew.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <cstdio>
#include "sparrowrenderer.h"
#include "glassert.h"
#include "camera.h"
#include "framebuffer.h"
#include "module.h"
#include <chrono>
@ -60,6 +63,7 @@ void SparrowRenderer::resizeGL(int width, int height)
void SparrowRenderer::renderGL()
{
FrameBuffer::screen->bindFBO();
glAssert(glClearColor(clearColor.r, clearColor.g, clearColor.b, 1));
glAssert(glClearDepth(1.0));
glAssert(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));