Archived
Private
Public Access
1
0

Initial commit

This commit is contained in:
2022-09-04 12:45:01 +02:00
commit f4a01d6a69
11601 changed files with 4206660 additions and 0 deletions

32
C#/TSEngine/Core/GL/gl.ts Normal file
View File

@@ -0,0 +1,32 @@
namespace TSE {
/** The WebGL rendering context. */
export var gl: WebGLRenderingContext;
/**
* Responsible for setting up a WebGL rendering context.
* */
export class GLUtilities {
/**
* Initialize WebGL
* @param elementId The id of the canvas element for rendering the game output.
*/
public static initialize(elementId?: string): HTMLCanvasElement {
let canvas: HTMLCanvasElement;
if (elementId !== undefined)
canvas = document.getElementById(elementId) as HTMLCanvasElement;
if (elementId === undefined) {
canvas = document.createElement("canvas") as HTMLCanvasElement;
document.body.appendChild(canvas);
}
gl = canvas.getContext("webgl");
if (gl === undefined)
throw new Error("Unable to initialize WebGL");
return canvas;
}
}
}