diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2019-05-20 19:53:16 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2019-05-21 06:21:21 +1000 |
commit | 9fc17c14fa682984742e8febd7551dd18bc36726 (patch) | |
tree | 681f7cb05ab4c5c5eb0beef86002db81301ace86 /src/plugins/platforms | |
parent | 800941df899a4418d4ac6cebbcc31a40120167bc (diff) |
wasm: fix QSGContext warning message
When runing the scenegraph example sgengine, gets rid if this error:
QSGContext::initialize: stencil buffer support missing, expect
rendering errors
Change-Id: I7f3a82409bc2cf81cf8217876e527f9c45be3bf4
Fixes: QTBUG-74694
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmopenglcontext.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index ae43e2ebf0..1658f32f9e 100644 --- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -37,6 +37,14 @@ QWasmOpenGLContext::QWasmOpenGLContext(const QSurfaceFormat &format) : m_requestedFormat(format) { m_requestedFormat.setRenderableType(QSurfaceFormat::OpenGLES); + + // if we set one, we need to set the other as well since in webgl, these are tied together + if (format.depthBufferSize() < 0 && format.stencilBufferSize() > 0) + m_requestedFormat.setDepthBufferSize(16); + + if (format.stencilBufferSize() < 0 && format.depthBufferSize() > 0) + m_requestedFormat.setStencilBufferSize(8); + } QWasmOpenGLContext::~QWasmOpenGLContext() @@ -91,10 +99,14 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(cons attributes.majorVersion = 2; } + // WebGL doesn't allow separate attach buffers to STENCIL_ATTACHMENT and DEPTH_ATTACHMENT + // we need both or none + bool useDepthStencil = (format.depthBufferSize() > 0 || format.stencilBufferSize() > 0); + // WebGL offers enable/disable control but not size control for these attributes.alpha = format.alphaBufferSize() > 0; - attributes.depth = format.depthBufferSize() > 0; - attributes.stencil = format.stencilBufferSize() > 0; + attributes.depth = useDepthStencil; + attributes.stencil = useDepthStencil; EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toLocal8Bit().constData(), &attributes); |