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

Fix: webgl-1 support #10410

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/environment-browser/BrowserAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export const BrowserAdapter = {
return canvas;
},
getCanvasRenderingContext2D: () => CanvasRenderingContext2D,
getWebGLRenderingContext: () => WebGLRenderingContext,
getWebGL2RenderingContext: () => WebGL2RenderingContext,
getWebGL1RenderingContext: () => WebGLRenderingContext,
Zyie marked this conversation as resolved.
Show resolved Hide resolved
getNavigator: () => navigator,
getBaseUrl: () => (document.baseURI ?? window.location.href),
getFontFaceSet: () => document.fonts,
Expand Down
3 changes: 1 addition & 2 deletions src/environment-webworker/WebWorkerAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { DOMParser } from '@xmldom/xmldom';
export const WebWorkerAdapter = {
createCanvas: (width?: number, height?: number) => new OffscreenCanvas(width ?? 0, height ?? 0),
getCanvasRenderingContext2D: () => OffscreenCanvasRenderingContext2D,
getWebGLRenderingContext: () => WebGLRenderingContext,
getWebGL2RenderingContext: () => WebGL2RenderingContext,
getWebGL1RenderingContext: () => WebGLRenderingContext,
getNavigator: () => navigator,
getBaseUrl: () => globalThis.location.href,
getFontFaceSet: () => (globalThis as unknown as WorkerGlobalScope).fonts,
Expand Down
4 changes: 1 addition & 3 deletions src/environment/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ export interface Adapter
/** Returns a 2D rendering context. */
getCanvasRenderingContext2D: () => { prototype: ICanvasRenderingContext2D; };
/** Returns a WebGL rendering context. */
getWebGLRenderingContext: () => typeof WebGLRenderingContext;
/** Returns a WebGL2 rendering context. */
getWebGL2RenderingContext: () => typeof WebGL2RenderingContext;
getWebGL1RenderingContext: () => typeof WebGLRenderingContext;
/** Returns a partial implementation of the browsers window.navigator */
getNavigator: () => { userAgent: string, gpu: GPU | null };
/** Returns the current base URL For browser environments this is either the document.baseURI or window.location.href */
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/renderers/gl/context/GlContextSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export class GlContextSystem implements System<ContextSystemOptions>
{
this.gl = gl;

this.webGLVersion = gl instanceof DOMAdapter.get().getWebGL2RenderingContext() ? 2 : 1;
this.webGLVersion = gl instanceof DOMAdapter.get().getWebGL1RenderingContext() ? 1 : 2;

this.getExtensions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function mapFormatToGlInternalFormat(
let srgb = {};
let bgra8unorm: number = gl.RGBA;

if (gl instanceof DOMAdapter.get().getWebGL2RenderingContext())
if (!(gl instanceof DOMAdapter.get().getWebGL1RenderingContext()))
{
srgb = {
'rgba8unorm-srgb': gl.SRGB8_ALPHA8,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/browser/isWebGLSupported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function isWebGLSupported(

try
{
if (!DOMAdapter.get().getWebGLRenderingContext())
if (!DOMAdapter.get().getWebGL1RenderingContext())
{
return false;
}
Expand Down