本文整理汇总了C++中GLTexture::getID方法的典型用法代码示例。如果您正苦于以下问题:C++ GLTexture::getID方法的具体用法?C++ GLTexture::getID怎么用?C++ GLTexture::getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLTexture
的用法示例。
在下文中一共展示了GLTexture::getID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveTextureToBmp
BitmapPtr BmpTextureMover::moveTextureToBmp(GLTexture& tex, int mipmapLevel)
{
GLContext* pContext = GLContext::getCurrent();
unsigned fbo = pContext->genFBO();
glproc::BindFramebuffer(GL_FRAMEBUFFER, fbo);
glproc::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
tex.getID(), mipmapLevel);
FBO::checkError("BmpTextureMover::moveTextureToBmp");
IntPoint size = tex.getMipmapSize(mipmapLevel);
BitmapPtr pBmp(new Bitmap(size, getPF()));
if (GLContext::getMain()->isGLES() && getPF() == B5G6R5) {
BitmapPtr pTmpBmp(new Bitmap(size, R8G8B8));
glReadPixels(0, 0, size.x, size.y, GL_RGB, GL_UNSIGNED_BYTE, pTmpBmp->getPixels());
FilterFlipRGB().applyInPlace(pTmpBmp);
pBmp->copyPixels(*pTmpBmp);
} else {
int glPixelFormat = tex.getGLFormat(getPF());
glReadPixels(0, 0, size.x, size.y, glPixelFormat, tex.getGLType(getPF()),
pBmp->getPixels());
}
GLContext::checkError("BmpTextureMover::moveTextureToBmp: glReadPixels()");
glproc::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
0, 0);
pContext->returnFBOToCache(fbo);
glproc::BindFramebuffer(GL_FRAMEBUFFER, 0);
return pBmp;
}
示例2: attach
void GLFramebuffer::attach(const string &attachment, GLenum txrFormat)
{
GLenum colorFormat, datatype;
if((colorFormat = getColorFormat(txrFormat)) == GL_NONE || (datatype = getDatatype(txrFormat)) == GL_NONE)
{
cerr << "Invalid texture format specified." << endl;
cerr << "Should be one of: GL_RGB32(F/UI), GL_RGBA32(F/UI), GL_DEPTH_COMPONENT32F." << endl;
return;
}
// Get FBO attachment slot for the new texture
GLenum slot = findAttachmentSlot(txrFormat);
GLTexture *pTexture = new GLTexture();
GLTexture::bind(0, *pTexture);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, txrFormat, m_width, m_height, 0, colorFormat, datatype, nullptr);
glFramebufferTexture2D(GL_FRAMEBUFFER, slot, GL_TEXTURE_2D, pTexture->getID(), 0);
GLTexture::unbind(0);
// Construct new FBO attachment
GLFramebufferAttachment fboAttachment;
fboAttachment.name = attachment;
fboAttachment.pTexture = pTexture;
fboAttachment.textureFormat = txrFormat;
fboAttachment.colorFormat = colorFormat;
fboAttachment.datatype = datatype;
fboAttachment.attachmentSlot = slot;
m_attachments.insert({attachment, fboAttachment});
// Increment color attachment count if neccessary
if(txrFormat != GL_DEPTH_COMPONENT32F) m_colorAttachmentCount++;
}