diff options
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 3 | ||||
-rw-r--r-- | src/opengl/qgl.cpp | 32 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 2 | ||||
-rw-r--r-- | src/opengl/qglframebufferobject.cpp | 22 | ||||
-rw-r--r-- | src/opengl/qglpaintdevice.cpp | 1 |
5 files changed, 47 insertions, 13 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 6365a7421b..cc97bed3f7 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -2099,9 +2099,8 @@ bool QGL2PaintEngineEx::end() d->device->endPaint(); ctx->d_ptr->active_engine = 0; - + ctx->makeCurrent(); d->resetOpenGLContextActiveEngine(); - d->resetGLState(); delete d->shaderManager; diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index d9f2113c14..e136ddcff2 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2104,17 +2104,17 @@ struct DDSFormat { would mirror the image and automatically generate mipmaps. This option helps preserve this default behavior. - \omitvalue CanFlipNativePixmapBindOption Used by x11 from pixmap to choose - whether or not it can bind the pixmap upside down or not. + \omitvalue CanFlipNativePixmapBindOption \omit Used by x11 from pixmap to choose + whether or not it can bind the pixmap upside down or not. \endomit - \omitvalue MemoryManagedBindOption Used by paint engines to + \omitvalue MemoryManagedBindOption \omit Used by paint engines to indicate that the pixmap should be memory managed along side with the pixmap/image that it stems from, e.g. installing destruction - hooks in them. + hooks in them. \endomit - \omitvalue TemporarilyCachedBindOption Used by paint engines on some + \omitvalue TemporarilyCachedBindOption \omit Used by paint engines on some platforms to indicate that the pixmap or image texture is possibly - cached only temporarily and must be destroyed immediately after the use. + cached only temporarily and must be destroyed immediately after the use. \endomit \omitvalue InternalBindOption */ @@ -3603,7 +3603,8 @@ void QGLContext::makeCurrent() \fn void QGLContext::swapBuffers() const Call this to finish a frame of OpenGL rendering, and make sure to - call makeCurrent() again before you begin a new frame. + call makeCurrent() again before issuing any further OpenGL commands, + for example as part of a new frame. */ void QGLContext::swapBuffers() const { @@ -4084,7 +4085,13 @@ bool QGLWidget::isSharing() const void QGLWidget::makeCurrent() { Q_D(QGLWidget); - d->glcx->makeCurrent(); + d->makeCurrent(); +} + +bool QGLWidgetPrivate::makeCurrent() +{ + glcx->makeCurrent(); + return QGLContext::currentContext() == glcx; } /*! @@ -4422,7 +4429,8 @@ void QGLWidget::resizeEvent(QResizeEvent *e) QWidget::resizeEvent(e); if (!isValid()) return; - makeCurrent(); + if (!d->makeCurrent()) + return; if (!d->glcx->initialized()) glInit(); const qreal scaleFactor = (window() && window()->windowHandle()) ? @@ -4537,7 +4545,8 @@ void QGLWidget::glInit() Q_D(QGLWidget); if (!isValid()) return; - makeCurrent(); + if (!d->makeCurrent()) + return; initializeGL(); d->glcx->setInitialized(true); } @@ -4555,7 +4564,8 @@ void QGLWidget::glDraw() Q_D(QGLWidget); if (!isValid()) return; - makeCurrent(); + if (!d->makeCurrent()) + return; #ifndef QT_OPENGL_ES if (d->glcx->deviceIsPixmap() && !d->glcx->contextHandle()->isOpenGLES()) qgl1_functions()->glDrawBuffer(GL_FRONT); diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 6b4d83888f..ed364283cc 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -145,6 +145,8 @@ public: glcx->reset(); } + bool makeCurrent(); + QGLContext *glcx; QGLWidgetGLPaintDevice glDevice; bool autoSwap; diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 0b386ededc..0b2ddf97fe 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -103,6 +103,14 @@ extern QImage qt_gl_read_frame_buffer(const QSize&, bool, bool); #define GL_DRAW_FRAMEBUFFER 0x8CA9 #endif +#ifndef GL_DEPTH_STENCIL_ATTACHMENT +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#endif + +#ifndef GL_DEPTH_STENCIL +#define GL_DEPTH_STENCIL 0x84F9 +#endif + /*! \class QGLFramebufferObjectFormat \inmodule QtOpenGL @@ -562,6 +570,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, funcs.glGenRenderbuffers(1, &depth_buffer); funcs.glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer); Q_ASSERT(funcs.glIsRenderbuffer(depth_buffer)); +#ifndef Q_OS_WASM if (samples != 0 && funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8, size.width(), size.height()); @@ -574,6 +583,19 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, GL_RENDERBUFFER, depth_buffer); funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil_buffer); +#else + // webgl does not allow separate depth and stencil attachments + if (samples != 0) { + funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, + GL_DEPTH_STENCIL, size.width(), size.height()); + } else { + funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, + size.width(), size.height()); + } + stencil_buffer = depth_buffer; + funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + GL_RENDERBUFFER, depth_buffer); +#endif valid = checkFramebufferStatus(); if (!valid) { diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index b29f71ad2e..c5151f66bb 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -126,6 +126,7 @@ void QGLPaintDevice::endPaint() { // Make sure the FBO bound at beginPaint is re-bound again here: QGLContext *ctx = context(); + ctx->makeCurrent(); ctx->d_func()->refreshCurrentFbo(); |