本文整理汇总了C++中TextureManager::RequestFreeUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureManager::RequestFreeUnit方法的具体用法?C++ TextureManager::RequestFreeUnit怎么用?C++ TextureManager::RequestFreeUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureManager
的用法示例。
在下文中一共展示了TextureManager::RequestFreeUnit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ItlGetGraphicCore
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;
}