From f2663f2ae4fabe975d2e2d5e3fe3afa4666e92f8 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 16 Dec 2014 16:31:37 +0100 Subject: [PATCH] Fix discard framebuffer support in QOpenGLWidget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The enum values are different for the default framebuffer and non-default ones. With QOpenGLWidget there is always a non-default fb bound, so the correct way is to use GL_COLOR_ATTACHMENT0 etc. GL_COLOR_EXT and friends are only allowed when the default framebuffer is bound, as per spec. Change-Id: Ia8c27038dc899e44d1a95eb88adbc1cac72652b0 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Jørgen Lind --- src/widgets/kernel/qopenglwidget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index a111a72e11..63ef4d6cc6 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -802,11 +802,11 @@ void QOpenGLWidgetPrivate::invalidateFbo() { QOpenGLExtensions *f = static_cast(QOpenGLContext::currentContext()->functions()); if (f->hasOpenGLExtension(QOpenGLExtensions::DiscardFramebuffer)) { - const int gl_color_ext = 0x1800; - const int gl_depth_ext = 0x1801; - const int gl_stencil_ext = 0x1802; + const int gl_color_attachment0 = 0x8CE0; // GL_COLOR_ATTACHMENT0 + const int gl_depth_attachment = 0x8D00; // GL_DEPTH_ATTACHMENT + const int gl_stencil_attachment = 0x8D20; // GL_STENCIL_ATTACHMENT const GLenum attachments[] = { - gl_color_ext, gl_depth_ext, gl_stencil_ext + gl_color_attachment0, gl_depth_attachment, gl_stencil_attachment }; f->glDiscardFramebufferEXT(GL_FRAMEBUFFER, sizeof attachments / sizeof *attachments, attachments); } else {