Skip to content

Commit

Permalink
fix(uno): Ensure that the canvas' context is active when rendering (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban authored Aug 17, 2023
1 parent 86e79cb commit d5bcfdf
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
this.currentRequest = window.requestAnimationFrame(() => {

if (this.requestRender) {
// make current for this canvas instance
GL.makeContextCurrent(this.glCtx);

this.requestRender();
}

Expand Down Expand Up @@ -178,12 +181,12 @@
throw `No <canvas> with id ${canvasOrCanvasId} was found`;
}

var ctx = SKSwapChainPanel.createWebGLContext(canvas);
if (!ctx || ctx < 0)
this.glCtx = SKSwapChainPanel.createWebGLContext(canvas);
if (!this.glCtx || this.glCtx < 0)
throw `Failed to create WebGL context: err ${ctx}`;

// make current
GL.makeContextCurrent(ctx);
GL.makeContextCurrent(this.glCtx);

// Starting from .NET 7 the GLctx is defined in an inaccessible scope
// when the current GL context changes. We need to pick it up from the
Expand All @@ -196,7 +199,7 @@
// read values
this.canvas = canvas;
return {
ctx: ctx,
ctx: this.glCtx,
fbo: currentGLctx.getParameter(currentGLctx.FRAMEBUFFER_BINDING),
stencil: currentGLctx.getParameter(currentGLctx.STENCIL_BITS),
sample: 0, // TODO: currentGLctx.getParameter(GLctx.SAMPLES)
Expand Down

0 comments on commit d5bcfdf

Please sign in to comment.