Type definitions for WebGL2

This commit is contained in:
Nico Kemnitz
2017-03-20 22:31:24 -04:00
parent 7c2a4738ea
commit 44102c1983
4 changed files with 1234 additions and 0 deletions
+1176
View File
File diff suppressed because it is too large Load Diff
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"webgl2-tests.ts"
]
}
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "../tslint.json",
"rules": {
"dt-header": false,
"adjacent-overload-signatures": false,
"unified-signatures": false,
"no-empty-interface": false
}
}
+26
View File
@@ -0,0 +1,26 @@
window.onload = () => {
const canvas: HTMLCanvasElement = document.createElement("canvas") as HTMLCanvasElement;
const gl: WebGL2RenderingContext | null = canvas.getContext("webgl2", { antialias: false} );
if (gl === null) {
console.log("WebGL2 not available");
return;
}
const maxsize = gl.getParameter(gl.MAX_3D_TEXTURE_SIZE);
console.log(`Attempting to create super useful, empty, NPOT 3D texture of size ${maxsize} x 13 x 5...`);
const texture = gl.createTexture();
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_3D, texture);
gl.texImage3D(gl.TEXTURE_3D, 0, gl.R32F, maxsize, 13, 5, 0, gl.RED, gl.FLOAT, null);
if (gl.getError() !== gl.NO_ERROR) {
console.log("Oh noes!");
} else {
console.log("Success!");
}
gl.deleteTexture(texture);
};