summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmopenglcontext.cpp
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@gmail.com>2019-01-31 14:06:39 +1000
committerMorten Johan Sørvig <morten.sorvig@qt.io>2019-03-08 10:09:46 +0000
commit452c644c5c51d78d72dde703c81fc7789e5b84f1 (patch)
treedeac1613356b3144e3e592479a2d55f35861e23d /src/plugins/platforms/wasm/qwasmopenglcontext.cpp
parent859f837d46a2e7f00a2f43d654a01c5de1b61b1f (diff)
wasm: make wasm platform target a specific canvas instead of default
This allows for multi canvas use Task-number: QTBUG-64079 Change-Id: I69c998aa4c2869bb5b7f14ba65bb63284365ad70 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmopenglcontext.cpp')
-rw-r--r--src/plugins/platforms/wasm/qwasmopenglcontext.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp
index 73af3d1878..e71da0c217 100644
--- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp
+++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp
@@ -28,7 +28,7 @@
****************************************************************************/
#include "qwasmopenglcontext.h"
-
+#include "qwasmintegration.h"
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
@@ -57,7 +57,9 @@ void QWasmOpenGLContext::maybeRecreateEmscriptenContext(QPlatformSurface *surfac
emscripten_webgl_destroy_context(m_context);
// Create new context
- const char *canvasId = 0; // (use default canvas) FIXME: get the actual canvas from the surface.
+ QWasmScreen *wasmScreen = QWasmIntegration::get()->screen();
+ const QString canvasId = wasmScreen->m_canvasId;
+ // FIXME: get the actual canvas from the surface.
m_context = createEmscriptenContext(canvasId, m_requestedFormat);
// Register context-lost callback.
@@ -73,11 +75,11 @@ void QWasmOpenGLContext::maybeRecreateEmscriptenContext(QPlatformSurface *surfac
return true;
};
bool capture = true;
- emscripten_set_webglcontextlost_callback(canvasId, this, capture, callback);
+ emscripten_set_webglcontextlost_callback(canvasId.toLocal8Bit().constData(), this, capture, callback);
}
}
-EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(const char *canvasId, QSurfaceFormat format)
+EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(const QString &canvasId, QSurfaceFormat format)
{
EmscriptenWebGLContextAttributes attributes;
emscripten_webgl_init_context_attributes(&attributes); // Populate with default attributes
@@ -96,7 +98,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(cons
attributes.depth = format.depthBufferSize() > 0;
attributes.stencil = format.stencilBufferSize() > 0;
- EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId, &attributes);
+ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toLocal8Bit().constData(), &attributes);
return context;
}