Allow users to pass canvas element
PiperOrigin-RevId: 518870611
This commit is contained in:
committed by
Copybara-Service
parent
5998e96eed
commit
1c9e6894f3
@@ -352,10 +352,15 @@ export class GraphRunner {
|
||||
} else {
|
||||
this.wasmModule._bindTextureToStream(streamNamePtr);
|
||||
}
|
||||
const gl: any =
|
||||
this.wasmModule.canvas.getContext('webgl2') ||
|
||||
this.wasmModule.canvas.getContext('webgl');
|
||||
console.assert(gl);
|
||||
const gl =
|
||||
(this.wasmModule.canvas.getContext('webgl2') ||
|
||||
this.wasmModule.canvas.getContext('webgl')) as WebGL2RenderingContext |
|
||||
WebGLRenderingContext | null;
|
||||
if (!gl) {
|
||||
throw new Error(
|
||||
'Failed to obtain WebGL context from the provided canvas. ' +
|
||||
'`getContext()` should only be invoked with `webgl` or `webgl2`.');
|
||||
}
|
||||
gl.texImage2D(
|
||||
gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imageSource);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user