diff --git a/src/light.cpp b/src/light.cpp index 8dced5a..7696a09 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -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* entityIt = scene->getGeometry(); @@ -96,7 +100,7 @@ void Light::generateShadowMap(Scene* scene) for(int j=0; jgetMesh()->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(); diff --git a/src/sparrowrenderer.cpp b/src/sparrowrenderer.cpp index 7d0c652..1ed01cc 100644 --- a/src/sparrowrenderer.cpp +++ b/src/sparrowrenderer.cpp @@ -1,8 +1,11 @@ #include +#include +#include #include #include "sparrowrenderer.h" #include "glassert.h" #include "camera.h" +#include "framebuffer.h" #include "module.h" #include @@ -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));