本文整理汇总了C++中QOpenGLFunctions::glGenerateMipmap方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions::glGenerateMipmap方法的具体用法?C++ QOpenGLFunctions::glGenerateMipmap怎么用?C++ QOpenGLFunctions::glGenerateMipmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFunctions
的用法示例。
在下文中一共展示了QOpenGLFunctions::glGenerateMipmap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bind
void SSGTexture::bind()
{
QOpenGLContext *context = QOpenGLContext::currentContext();
QOpenGLFunctions *funcs = context->functions();
if (!m_dirty_texture) {
funcs->glBindTexture(GL_TEXTURE_2D, m_texture_id);
if ((minMipmapFiltering() != SSGTexture::None || magMipmapFiltering() != SSGTexture::None) && !m_mipmaps_generated) {
funcs->glGenerateMipmap(GL_TEXTURE_2D);
m_mipmaps_generated = true;
}
updateBindOptions(m_dirty_bind_options);
m_dirty_bind_options = false;
return;
}
m_dirty_texture = false;
if (!m_image || !m_image->isValid()) {
if (m_texture_id && m_owns_texture) {
funcs->glDeleteTextures(1, &m_texture_id);
}
m_texture_id = 0;
m_texture_size = QSize();
m_has_alpha = false;
return;
}
if (m_texture_id == 0)
funcs->glGenTextures(1, &m_texture_id);
funcs->glBindTexture(GL_TEXTURE_2D, m_texture_id);
updateBindOptions(m_dirty_bind_options);
funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, m_texture_size.width(), m_texture_size.height(), 0, GL_RGBA, GL_UNSIGNED_SHORT, m_image->rawData().get());
if (minMipmapFiltering() != SSGTexture::None || magMipmapFiltering() != SSGTexture::None) {
funcs->glGenerateMipmap(GL_TEXTURE_2D);
m_mipmaps_generated = true;
}
m_texture_rect = QRectF(0, 0, 1, 1);
m_dirty_bind_options = false;
// if (!m_retain_image)
// m_image.reset();
}
示例2: grab
//.........这里部分代码省略.........
updateBindOptions(true);
m_depthStencilBuffer = m_context->depthStencilBufferForFbo(m_secondaryFbo);
} else {
delete m_fbo;
delete m_secondaryFbo;
m_fbo = new QOpenGLFramebufferObject(m_size, format);
m_secondaryFbo = 0;
funcs->glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
updateBindOptions(true);
m_depthStencilBuffer = m_context->depthStencilBufferForFbo(m_fbo);
}
}
}
if (m_recursive && !m_secondaryFbo) {
// m_fbo already created, m_recursive was just set.
Q_ASSERT(m_fbo);
Q_ASSERT(!m_multisampling);
m_secondaryFbo = new QOpenGLFramebufferObject(m_size, m_fbo->format());
funcs->glBindTexture(GL_TEXTURE_2D, m_secondaryFbo->texture());
updateBindOptions(true);
}
// Render texture.
root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip and opacity update.
m_renderer->nodeChanged(root, QSGNode::DirtyForceUpdate); // Force render list update.
#ifdef QSG_DEBUG_FBO_OVERLAY
if (qmlFboOverlay()) {
if (!m_debugOverlay)
m_debugOverlay = new QSGSimpleRectNode();
m_debugOverlay->setRect(QRectF(0, 0, m_size.width(), m_size.height()));
m_debugOverlay->setColor(QColor(0xff, 0x00, 0x80, 0x40));
root->appendChildNode(m_debugOverlay);
}
#endif
m_dirtyTexture = false;
m_renderer->setDeviceRect(m_size);
m_renderer->setViewportRect(m_size);
QRectF mirrored(m_mirrorHorizontal ? m_rect.right() : m_rect.left(),
m_mirrorVertical ? m_rect.bottom() : m_rect.top(),
m_mirrorHorizontal ? -m_rect.width() : m_rect.width(),
m_mirrorVertical ? -m_rect.height() : m_rect.height());
m_renderer->setProjectionMatrixToRect(mirrored);
m_renderer->setClearColor(Qt::transparent);
if (m_multisampling) {
m_renderer->renderScene(BindableFbo(m_secondaryFbo, m_depthStencilBuffer.data()));
if (deleteFboLater) {
delete m_fbo;
QOpenGLFramebufferObjectFormat format;
format.setInternalTextureFormat(m_format);
format.setAttachment(QOpenGLFramebufferObject::NoAttachment);
format.setMipmap(m_mipmap);
format.setSamples(0);
m_fbo = new QOpenGLFramebufferObject(m_size, format);
funcs->glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
updateBindOptions(true);
}
QRect r(QPoint(), m_size);
QOpenGLFramebufferObject::blitFramebuffer(m_fbo, r, m_secondaryFbo, r);
} else {
if (m_recursive) {
m_renderer->renderScene(BindableFbo(m_secondaryFbo, m_depthStencilBuffer.data()));
if (deleteFboLater) {
delete m_fbo;
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setInternalTextureFormat(m_format);
format.setMipmap(m_mipmap);
m_fbo = new QOpenGLFramebufferObject(m_size, format);
funcs->glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
updateBindOptions(true);
}
qSwap(m_fbo, m_secondaryFbo);
} else {
m_renderer->renderScene(BindableFbo(m_fbo, m_depthStencilBuffer.data()));
}
}
if (m_mipmap) {
funcs->glBindTexture(GL_TEXTURE_2D, textureId());
funcs->glGenerateMipmap(GL_TEXTURE_2D);
}
root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip, opacity and render list update.
#ifdef QSG_DEBUG_FBO_OVERLAY
if (qmlFboOverlay())
root->removeChildNode(m_debugOverlay);
#endif
if (m_recursive)
markDirtyTexture(); // Continuously update if 'live' and 'recursive'.
}