diff options
Diffstat (limited to 'src/gui/opengl/qopenglbuffer.cpp')
-rw-r--r-- | src/gui/opengl/qopenglbuffer.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/gui/opengl/qopenglbuffer.cpp b/src/gui/opengl/qopenglbuffer.cpp index 69c2baa8d9..537097c09f 100644 --- a/src/gui/opengl/qopenglbuffer.cpp +++ b/src/gui/opengl/qopenglbuffer.cpp @@ -43,6 +43,10 @@ #include "qopenglbuffer.h" #include <private/qopenglextensions_p.h> +#ifndef GL_CONTEXT_LOST +#define GL_CONTEXT_LOST 0x0507 +#endif + QT_BEGIN_NAMESPACE /*! @@ -59,12 +63,7 @@ QT_BEGIN_NAMESPACE QOpenGLBuffer objects can be copied around as a reference to the underlying OpenGL buffer object: - \code - QOpenGLBuffer buffer1(QOpenGLBuffer::IndexBuffer); - buffer1.create(); - - QOpenGLBuffer buffer2 = buffer1; - \endcode + \snippet code/src_gui_opengl_qopenglbuffer.cpp 0 QOpenGLBuffer performs a shallow copy when objects are copied in this manner, but does not implement copy-on-write semantics. The original @@ -346,7 +345,14 @@ bool QOpenGLBuffer::read(int offset, void *data, int count) Q_D(QOpenGLBuffer); if (!d->funcs->hasOpenGLFeature(QOpenGLFunctions::Buffers) || !d->guard->id()) return false; - while (d->funcs->glGetError() != GL_NO_ERROR) ; // Clear error state. + + while (true) { // Clear error state. + GLenum error = d->funcs->glGetError(); + if (error == GL_NO_ERROR) + break; + if (error == GL_CONTEXT_LOST) + return false; + }; d->funcs->glGetBufferSubData(d->type, offset, count, data); return d->funcs->glGetError() == GL_NO_ERROR; #else @@ -473,9 +479,7 @@ void QOpenGLBuffer::release() been bound to the context but wants to make sure that it is released. - \code - QOpenGLBuffer::release(QOpenGLBuffer::VertexBuffer); - \endcode + \snippet code/src_gui_opengl_qopenglbuffer.cpp 1 */ void QOpenGLBuffer::release(QOpenGLBuffer::Type type) { |