summaryrefslogtreecommitdiffstats
path: root/src/openglwidgets/qopenglwidget.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2023-07-21 13:48:35 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2023-07-25 23:05:50 +0200
commit8cc8bbb466fb871585bfa1d5c56fc8bc6d6c8a96 (patch)
tree53bcdf2fc7b1e125fb87f1abdcce0fbc3766725f /src/openglwidgets/qopenglwidget.cpp
parentabe7c77d6d095c684f2e725f02638f062aea029c (diff)
QOpenGLWidget: use (and prefer) InvalidateFramebuffer
Desktop GL does not have the GL_EXT_discard_framebuffer extension at all. Instead, it may have GL_ARB_invalidate_subdata. Furthermore, GLES >= 3.0 and GL >= 4.3 both support FBO invalidation through glInvalidateFramebuffer. Extend the semantics of OpenGLExtension::DiscardFramebuffer to mean that *any* possibility above is supported, and wrap it in a helper function that calls whatever support is present. (This is all private API anyhow.) Technically speaking glInvalidateFramebuffer supports a superset of what glDiscardFramebufferEXT supports, but we never use such superset, and the two APIs are otherwise identical. Then, make QOpenGLWidget call that wrapper. Change-Id: I64e042daf51493d3834c3ba1b53ae6e224bbc4ed Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/openglwidgets/qopenglwidget.cpp')
-rw-r--r--src/openglwidgets/qopenglwidget.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/openglwidgets/qopenglwidget.cpp b/src/openglwidgets/qopenglwidget.cpp
index 5fae60ee17..1733706437 100644
--- a/src/openglwidgets/qopenglwidget.cpp
+++ b/src/openglwidgets/qopenglwidget.cpp
@@ -504,9 +504,8 @@ QT_BEGIN_NAMESPACE
benefits on certain hardware architectures common in the mobile and
embedded space when a framebuffer object is used as the rendering target.
The framebuffer object is invalidated between frames with
- glDiscardFramebufferEXT if supported or a glClear. Please see the
- documentation of EXT_discard_framebuffer for more information:
- https://www.khronos.org/registry/gles/extensions/EXT/EXT_discard_framebuffer.txt
+ glInvalidateFramebuffer (if supported), or, as fallbacks,
+ glDiscardFramebufferEXT (if supported) or a call to glClear.
\value PartialUpdate The framebuffer objects color buffer and ancillary
buffers are not invalidated between frames.
@@ -1000,7 +999,7 @@ void QOpenGLWidgetPrivate::invalidateFbo()
gl_color_attachment0, gl_depth_attachment, gl_stencil_attachment
};
#endif
- f->glDiscardFramebufferEXT(GL_FRAMEBUFFER, sizeof attachments / sizeof *attachments, attachments);
+ f->discardFramebuffer(GL_FRAMEBUFFER, GLsizei(std::size(attachments)), attachments);
} else {
f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}