Upgraded WebGL context, closes #141, closes #123

This commit is contained in:
Lucas Dower 2023-09-03 17:30:22 +01:00
parent dc87550bc5
commit f68492cadd
No known key found for this signature in database
GPG Key ID: B3EE6B8499593605

View File

@ -56,7 +56,7 @@ type InternalTextureMaterial = {
};
export class Renderer {
public _gl: WebGLRenderingContext;
public _gl: WebGL2RenderingContext;
private _backgroundColour: RGBA = { r: 0.125, g: 0.125, b: 0.125, a: 1.0 };
private _atlasTexture?: WebGLTexture;
@ -99,9 +99,15 @@ export class Renderer {
}
private constructor() {
this._gl = (<HTMLCanvasElement>document.getElementById('canvas')).getContext('webgl', {
const webgl2Context = (<HTMLCanvasElement>document.getElementById('canvas')).getContext('webgl2', {
alpha: false,
})!;
});
if (webgl2Context === null) {
throw 'Could not get WebGL2';
}
this._gl = webgl2Context;
twgl.addExtensionsToContext(this._gl);
this._backgroundColour = AppConfig.Get.VIEWPORT_BACKGROUND_COLOUR;