void Bamboo::RN_Deferred::ItlCreateFBO() { TextureManager *pTextureManager = ItlGetGraphicCore()->GetTextureManager(); assert (pTextureManager != NULL); //get the id of a free texture unit from the texture manager GLuint nUsedTextureUnit = pTextureManager->RequestFreeUnit(); //ask for a free texture unit //activate unit glActiveTexture(GL_TEXTURE0 + nUsedTextureUnit); m_nAlbedoDrawBuffer = ItlCreateColorTexture(); m_nNormalMapDrawBuffer = ItlCreateColorTexture(); m_nNormalDrawBuffer = ItlCreateColorTexture(); m_nTangentDrawBuffer = ItlCreateColorTexture(); m_nSpecularDrawBuffer = ItlCreateColorTexture(); m_nDepthDrawBuffer = ItlCreateDepthTexture(); m_nDisplaceDrawBuffer = ItlCreateColorTexture(); m_nPositionDrawBuffer = ItlCreateColorTexture(); m_nStencilDrawBuffer = ItlCreateColorTexture(); glGenFramebuffers(1, &m_nFBO); glBindFramebuffer(GL_FRAMEBUFFER, m_nFBO); // attach the texture to FBO color attachment point glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_nAlbedoDrawBuffer, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, m_nNormalDrawBuffer, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, m_nTangentDrawBuffer, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_nSpecularDrawBuffer, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT4, GL_TEXTURE_2D, m_nDisplaceDrawBuffer, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT5, GL_TEXTURE_2D, m_nPositionDrawBuffer, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT6, GL_TEXTURE_2D, m_nNormalMapDrawBuffer, 0); // attach the renderbuffer to depth attachment point glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_nDepthDrawBuffer, 0); GLenum tDrawBuffers[7] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 , GL_COLOR_ATTACHMENT3, GL_COLOR_ATTACHMENT4, GL_COLOR_ATTACHMENT5, GL_COLOR_ATTACHMENT6 }; glDrawBuffers(7, tDrawBuffers); //check fbo status GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if(status != GL_FRAMEBUFFER_COMPLETE) Logger::fatal() << "Failed to initialize FBO for RN_Deferred" << Logger::endl; //release used texture unit pTextureManager->ReleaseUnit(nUsedTextureUnit); //unbind fbo glBindFramebuffer(GL_FRAMEBUFFER, 0); m_bLayeredFBO = false; }