blit entire texture. Only issue is that it is upside down

This commit is contained in:
David Kelly 2017-06-16 15:30:36 -07:00
parent 9b5b99c2b9
commit 0f799e52f4
2 changed files with 24 additions and 9 deletions

View file

@ -826,16 +826,31 @@ void OpenGLDisplayPlugin::updateCompositeFramebuffer() {
void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(gpu::TexturePointer source, QOpenGLFramebufferObject* target) {
auto glBackend = const_cast<OpenGLDisplayPlugin&>(*this).getGLBackend();
withMainThreadContext([&] {
qDebug() << "initial gl error:" << glGetError();
GLuint sourceTexture = glBackend->getTextureID(source);
GLuint targetTexture = target->texture();
GLuint fbo { 0 };
glCreateFramebuffers(1, &fbo);
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sourceTexture, 0);
glCopyTextureSubImage2D(targetTexture, 0, 0, 0, 0, 0, target->width(), target->height());
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &fbo);
glDeleteTextures(1, &fbo);
GLuint fbo[2] {0, 0};
glGenerateTextureMipmap(sourceTexture);
qDebug() << "errors: " << glGetError();
glCreateFramebuffers(2, fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo[0]);
qDebug() << "errors: " << glGetError();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sourceTexture, 0);
qDebug() << "errors: " << glGetError();
glBindFramebuffer(GL_FRAMEBUFFER, fbo[1]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTexture, 0);
qDebug() << "errors: " << glGetError();
glBlitNamedFramebuffer(fbo[0], fbo[1], 0, 0, source->getWidth(), source->getHeight(), 0, 0, target->width(), target->height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
qDebug() << "errors: " << glGetError() << "bound?" << target->isBound();
glDeleteFramebuffers(2, fbo);
glDeleteTextures(1, fbo);
glFinish();
});
}

View file

@ -79,7 +79,7 @@ public:
// Three threads, one for rendering, one for texture transfers, one reserved for the GL driver
int getRequiredThreadCount() const override { return 3; }
void copyTextureToQuickFramebuffer(gpu::TexturePointer source, QOpenGLFramebufferObject* target);
void copyTextureToQuickFramebuffer(gpu::TexturePointer source, QOpenGLFramebufferObject* target) override;
protected:
friend class PresentThread;