mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:02:55 +02:00
blit entire texture. Only issue is that it is upside down
This commit is contained in:
parent
9b5b99c2b9
commit
0f799e52f4
2 changed files with 24 additions and 9 deletions
|
@ -826,16 +826,31 @@ void OpenGLDisplayPlugin::updateCompositeFramebuffer() {
|
||||||
void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(gpu::TexturePointer source, QOpenGLFramebufferObject* target) {
|
void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(gpu::TexturePointer source, QOpenGLFramebufferObject* target) {
|
||||||
auto glBackend = const_cast<OpenGLDisplayPlugin&>(*this).getGLBackend();
|
auto glBackend = const_cast<OpenGLDisplayPlugin&>(*this).getGLBackend();
|
||||||
withMainThreadContext([&] {
|
withMainThreadContext([&] {
|
||||||
|
qDebug() << "initial gl error:" << glGetError();
|
||||||
GLuint sourceTexture = glBackend->getTextureID(source);
|
GLuint sourceTexture = glBackend->getTextureID(source);
|
||||||
GLuint targetTexture = target->texture();
|
GLuint targetTexture = target->texture();
|
||||||
GLuint fbo { 0 };
|
GLuint fbo[2] {0, 0};
|
||||||
glCreateFramebuffers(1, &fbo);
|
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
|
glGenerateTextureMipmap(sourceTexture);
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sourceTexture, 0);
|
qDebug() << "errors: " << glGetError();
|
||||||
glCopyTextureSubImage2D(targetTexture, 0, 0, 0, 0, 0, target->width(), target->height());
|
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
glCreateFramebuffers(2, fbo);
|
||||||
glDeleteFramebuffers(1, &fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, fbo[0]);
|
||||||
glDeleteTextures(1, &fbo);
|
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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
// Three threads, one for rendering, one for texture transfers, one reserved for the GL driver
|
// Three threads, one for rendering, one for texture transfers, one reserved for the GL driver
|
||||||
int getRequiredThreadCount() const override { return 3; }
|
int getRequiredThreadCount() const override { return 3; }
|
||||||
|
|
||||||
void copyTextureToQuickFramebuffer(gpu::TexturePointer source, QOpenGLFramebufferObject* target);
|
void copyTextureToQuickFramebuffer(gpu::TexturePointer source, QOpenGLFramebufferObject* target) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class PresentThread;
|
friend class PresentThread;
|
||||||
|
|
Loading…
Reference in a new issue