Skip to content

Commit

Permalink
feat: iswebGl2 fixed (#202)
Browse files Browse the repository at this point in the history
* feat: iswebGl2 fixed

* fix: ts error fixed

* fix: namespace change

---------

Co-authored-by: duxinyue.dxy <[email protected]>
  • Loading branch information
XinyueDu and duxinyue.dxy authored Oct 9, 2024
1 parent 972cdeb commit 113e2e6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/webgl/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,23 @@ import type { Sampler_GL } from './Sampler';
import type { Texture_GL } from './Texture';

// @see https://github.com/visgl/luma.gl/blob/30a1039573576d73641de7c1ba222e8992eb526e/modules/gltools/src/utils/webgl-checks.ts#L22
let isWebGL2Flag;
export function isWebGL2(
gl: WebGL2RenderingContext | WebGLRenderingContext,
): gl is WebGL2RenderingContext {
if (
typeof WebGL2RenderingContext !== 'undefined' &&
gl instanceof WebGL2RenderingContext
) {
return true;

if(isWebGL2Flag !== undefined) {
return isWebGL2Flag;
}
if (typeof WebGL2RenderingContext !== 'undefined' &&
gl instanceof WebGL2RenderingContext) {
isWebGL2Flag = true;
return true;
}
// Look for debug contexts, headless gl etc
// @ts-ignore
return Boolean(gl && gl._version === 2);
isWebGL2Flag = Boolean(gl && gl._version === 2);
return isWebGL2Flag;
}

export function isTextureFormatCompressed(fmt: Format): boolean {
Expand Down

0 comments on commit 113e2e6

Please sign in to comment.