TP RTR
This commit is contained in:
parent
afcd38fcbe
commit
8b61fb264f
@ -87,15 +87,18 @@ void Light::initShadowMap(int resWidth, int resHeight, glm::vec3 dim)
|
||||
|
||||
void Light::generateShadowMap(Scene* scene)
|
||||
{
|
||||
glAssert(glViewport(0, 0, 512, 512));
|
||||
shadowMap->bindFBO();
|
||||
glAssert(glClearDepth(1.0));
|
||||
glAssert(glClear(GL_DEPTH_BUFFER_BIT));
|
||||
glAssert(glEnable(GL_DEPTH_TEST));
|
||||
glDepthFunc(GL_LESS);
|
||||
for(SceneIterator<PhongEntity*>* entityIt = scene->getGeometry();
|
||||
entityIt->isValid(); entityIt->next())
|
||||
{
|
||||
// compute matrix attributes
|
||||
PhongEntity* entity = entityIt->getItem();
|
||||
glm::mat4 modelViewMatrix = viewMatrix * entity->modelMatrix;
|
||||
glm::mat4 mvp = projectionMatrix * modelViewMatrix;
|
||||
glm::mat4 lightMVP = getProjectionMatrix() * (getViewMatrix() * entity->modelMatrix);
|
||||
// loop over material groups
|
||||
for(int j=0; j<entity->getMesh()->indiceGroups.size(); ++j)
|
||||
{
|
||||
@ -105,6 +108,7 @@ void Light::generateShadowMap(Scene* scene)
|
||||
PhongMaterial* pmat = (PhongMaterial*)mat;
|
||||
shaders[1]->bind();
|
||||
pmat->alpha_mask->bind(ALPHA_MASK);
|
||||
shaders[1]->bindMat4(shaders[1]->getLocation("MVP"), lightMVP);
|
||||
shaders[1]->bindInteger(shaders[1]->getLocation("alphaMask"), ALPHA_MASK);
|
||||
entity->drawGroup(j, false, true, false);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
bool SparrowRenderer::modernOpenglAvailable = false;
|
||||
|
||||
void SparrowRenderer::initGL(int width, int height, bool forceCrappy)
|
||||
void SparrowRenderer::initGL(int w, int h, bool forceCrappy)
|
||||
{
|
||||
glewExperimental = GL_TRUE;
|
||||
GLenum err = glewInit();
|
||||
@ -45,7 +45,7 @@ void SparrowRenderer::initGL(int width, int height, bool forceCrappy)
|
||||
glAssert(glEnable(GL_DEPTH_TEST));
|
||||
glAssert(glEnable(GL_CULL_FACE));
|
||||
glAssert(glEnable(GL_TEXTURE_2D));
|
||||
resizeGL(width, height);
|
||||
resizeGL(w, h);
|
||||
}
|
||||
|
||||
void SparrowRenderer::destroyGL()
|
||||
@ -55,14 +55,17 @@ void SparrowRenderer::destroyGL()
|
||||
modules.clear();
|
||||
}
|
||||
|
||||
void SparrowRenderer::resizeGL(int width, int height)
|
||||
void SparrowRenderer::resizeGL(int w, int h)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
glAssert(glViewport(0, 0, width, height));
|
||||
camera->resize(width, height);
|
||||
}
|
||||
|
||||
void SparrowRenderer::renderGL()
|
||||
{
|
||||
glAssert(glViewport(0, 0, width, height));
|
||||
FrameBuffer::screen->bindFBO();
|
||||
glAssert(glClearColor(clearColor.r, clearColor.g, clearColor.b, 1));
|
||||
glAssert(glClearDepth(1.0));
|
||||
|
@ -19,9 +19,9 @@ public:
|
||||
{}
|
||||
|
||||
// main methods
|
||||
void initGL(int width, int height, bool forceCrappy = false);
|
||||
void initGL(int w, int h, bool forceCrappy = false);
|
||||
void destroyGL();
|
||||
void resizeGL(int width, int height);
|
||||
void resizeGL(int w, int h);
|
||||
void renderGL();
|
||||
static bool isModernOpenGLAvailable();
|
||||
void setClearColor(glm::vec3 color) {clearColor=color;}
|
||||
@ -54,6 +54,8 @@ protected:
|
||||
s_moduleNode(Module* myModule, const std::string &myName) : module(myModule), name(myName), isEnabled(true) {}
|
||||
} ModuleNode;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
Camera* camera;
|
||||
Scene* scene;
|
||||
std::vector<ModuleNode> modules;
|
||||
|
Loading…
x
Reference in New Issue
Block a user