Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: iswebGl2 fixed #202

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading