本文整理汇总了C++中GLTexture::allocData2D方法的典型用法代码示例。如果您正苦于以下问题:C++ GLTexture::allocData2D方法的具体用法?C++ GLTexture::allocData2D怎么用?C++ GLTexture::allocData2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLTexture
的用法示例。
在下文中一共展示了GLTexture::allocData2D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setWidthAndHeight
void GLFramebuffer::setWidthAndHeight(unsigned int width, unsigned int height)
{
mWidth = std::max(width, 1u);
mHeight = std::max(height, 1u);
if (not mFinished)
{
return;
}
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
if (mDepthTexture != NULL)
{
GLTexture *glDepthTex = (GLTexture *)mDepthTexture;
glBindTexture(GL_TEXTURE_2D, glDepthTex->mTexture);
glDepthTex->allocData2D(mWidth, mHeight, mDepthFormat, Texture::Depth32F_Format, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, glDepthTex->mTexture, 0);
}
if (glIsRenderbuffer(mDepthRBO) and mDepthTexture == NULL)
{
glBindRenderbuffer(GL_RENDERBUFFER, mDepthRBO);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, mWidth, mHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthRBO);
}
unsigned int i=0;
GLenum drawBuffers[mColorTextures.size()];
for (std::vector<ColorTexture>::iterator it = mColorTextures.begin();
it != mColorTextures.end(); ++it)
{
GLTexture *glTexture = (GLTexture *)it->texture;
glBindTexture(GL_TEXTURE_2D, glTexture->mTexture);
glTexture->allocData2D(mWidth*it->scale.x, mHeight*it->scale.y, it->format, Texture::RGBU8_Format, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+i, GL_TEXTURE_2D, glTexture->mTexture, 0);
drawBuffers[i] = GL_COLOR_ATTACHMENT0+i;
++i;
}
glDrawBuffers(mColorTextures.size(), drawBuffers);
}