wasm: fix build issue in sw/wg build only case

- resolved EMSCRIPTEN_WEBGL_CONTEXT_HANDLE declaration problem.
- currentContext() should be also called after `mContext` is initialized.
This commit is contained in:
Jinny You 2025-01-10 16:26:40 +08:00 committed by Hermet Park
parent 07e73a9e6f
commit 4aba0caaad
2 changed files with 4 additions and 2 deletions

View file

@ -188,7 +188,7 @@ struct TvgWgEngine : TvgEngineMethod
struct TvgGLEngine : TvgEngineMethod struct TvgGLEngine : TvgEngineMethod
{ {
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = 0; intptr_t context = 0;
~TvgGLEngine() override ~TvgGLEngine() override
{ {
#ifdef THORVG_GL_RASTER_SUPPORT #ifdef THORVG_GL_RASTER_SUPPORT

View file

@ -797,7 +797,7 @@ bool GlRenderer::target(void* context, int32_t id, uint32_t w, uint32_t h)
//assume the context zero is invalid //assume the context zero is invalid
if (!context || id == GL_INVALID_VALUE || w == 0 || h == 0) return false; if (!context || id == GL_INVALID_VALUE || w == 0 || h == 0) return false;
currentContext(); if (mContext) currentContext();
flush(); flush();
@ -808,6 +808,8 @@ bool GlRenderer::target(void* context, int32_t id, uint32_t w, uint32_t h)
mContext = context; mContext = context;
mTargetFboId = static_cast<GLint>(id); mTargetFboId = static_cast<GLint>(id);
currentContext();
mRootTarget = GlRenderTarget(surface.w, surface.h); mRootTarget = GlRenderTarget(surface.w, surface.h);
mRootTarget.setViewport({0, 0, static_cast<int32_t>(surface.w), static_cast<int32_t>(surface.h)}); mRootTarget.setViewport({0, 0, static_cast<int32_t>(surface.w), static_cast<int32_t>(surface.h)});
mRootTarget.init(mTargetFboId); mRootTarget.init(mTargetFboId);