fixed renderer clearing last used FBO instead of clearing screen
This commit is contained in:
parent
2760f0c38f
commit
afcd38fcbe
@ -62,6 +62,12 @@ bool Light::isDirectionnal()
|
|||||||
|
|
||||||
void Light::initShadowMap(int resWidth, int resHeight, glm::vec3 dim)
|
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;
|
shadowCaster = true;
|
||||||
shadowMap = new FrameBuffer();
|
shadowMap = new FrameBuffer();
|
||||||
// Depth buffer
|
// Depth buffer
|
||||||
@ -81,8 +87,6 @@ void Light::initShadowMap(int resWidth, int resHeight, glm::vec3 dim)
|
|||||||
|
|
||||||
void Light::generateShadowMap(Scene* scene)
|
void Light::generateShadowMap(Scene* scene)
|
||||||
{
|
{
|
||||||
viewMatrix = glm::lookAt(position, position+direction, glm::vec3(0, 1, 0));
|
|
||||||
|
|
||||||
shadowMap->bindFBO();
|
shadowMap->bindFBO();
|
||||||
glAssert(glEnable(GL_DEPTH_TEST));
|
glAssert(glEnable(GL_DEPTH_TEST));
|
||||||
for(SceneIterator<PhongEntity*>* entityIt = scene->getGeometry();
|
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)
|
for(int j=0; j<entity->getMesh()->indiceGroups.size(); ++j)
|
||||||
{
|
{
|
||||||
Material* mat = entity->getMesh()->indiceGroups[j].material;
|
Material* mat = entity->getMesh()->indiceGroups[j].material;
|
||||||
if(mat->getFlags() & ALPHA_MASK)
|
if(mat->getFlags() & ALPHA_MASK_FLAG)
|
||||||
{
|
{
|
||||||
PhongMaterial* pmat = (PhongMaterial*)mat;
|
PhongMaterial* pmat = (PhongMaterial*)mat;
|
||||||
shaders[1]->bind();
|
shaders[1]->bind();
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
#include <glew/glew.h>
|
#include <glew/glew.h>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glext.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "sparrowrenderer.h"
|
#include "sparrowrenderer.h"
|
||||||
#include "glassert.h"
|
#include "glassert.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
|
#include "framebuffer.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
@ -60,6 +63,7 @@ void SparrowRenderer::resizeGL(int width, int height)
|
|||||||
|
|
||||||
void SparrowRenderer::renderGL()
|
void SparrowRenderer::renderGL()
|
||||||
{
|
{
|
||||||
|
FrameBuffer::screen->bindFBO();
|
||||||
glAssert(glClearColor(clearColor.r, clearColor.g, clearColor.b, 1));
|
glAssert(glClearColor(clearColor.r, clearColor.g, clearColor.b, 1));
|
||||||
glAssert(glClearDepth(1.0));
|
glAssert(glClearDepth(1.0));
|
||||||
glAssert(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
glAssert(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user