Fix discard framebuffer support in QOpenGLWidget

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 <giuseppe.dangelo@kdab.com>
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
This commit is contained in:
Laszlo Agocs 2014-12-16 16:31:37 +01:00
parent e78ec1c48a
commit f2663f2ae4

View File

@ -802,11 +802,11 @@ void QOpenGLWidgetPrivate::invalidateFbo()
{
QOpenGLExtensions *f = static_cast<QOpenGLExtensions *>(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 {