shadowmapping #2
4 changed files with 15 additions and 2 deletions
|
@ -36,4 +36,7 @@ void loadImg(const char *filename, const GLuint texture);
|
|||
// Copy a texture
|
||||
void copyTexture(const GLuint, const GLuint);
|
||||
|
||||
// Get the current FBO ID
|
||||
GLuint getCurrentFramebufferID(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -76,6 +76,7 @@ static void transition_draw(void (*a0)(int), void (*a1)(int), Uint32 t,
|
|||
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
|
||||
(GLint *)&_transition_tId);
|
||||
GLint currentFramebufferID = getCurrentFramebufferID();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _transition_fbo[0]);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||
|
@ -91,7 +92,7 @@ static void transition_draw(void (*a0)(int), void (*a1)(int), Uint32 t,
|
|||
a1(state);
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, currentFramebufferID);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||
_transition_tId, 0);
|
||||
|
||||
|
|
|
@ -92,6 +92,8 @@ static void draw(void) {
|
|||
gl4duLookAtf(9, 6, 0, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
||||
glCullFace(GL_FRONT);
|
||||
|
||||
GLint currentFramebufferID = getCurrentFramebufferID();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _fbo);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,
|
||||
_shadow_map_tex, 0);
|
||||
|
@ -100,7 +102,7 @@ static void draw(void) {
|
|||
for (int i = 0; i < HEROS_NUMBER; ++i) {
|
||||
drawManifestant(matrix_model, &_herosId[i], deplacement, GL_TRUE);
|
||||
}
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, currentFramebufferID);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
|
|
|
@ -88,3 +88,10 @@ void copyTexture(const GLuint src, const GLuint dst) {
|
|||
SDL_FreeSurface(s);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
GLuint getCurrentFramebufferID(void) {
|
||||
GLint currentFramebufferID = 0;
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFramebufferID);
|
||||
|
||||
return currentFramebufferID;
|
||||
}
|
||||
|
|
Reference in a new issue