Skip to content

Commit 947eee9

Browse files
authored
Merge pull request #130 from WICG/progers-update-webgl-demo
Update webgl demo to support new syntax
2 parents 2a3c35d + 89a5486 commit 947eee9

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

Examples/webGL.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,21 @@
5656
const texture = gl.createTexture();
5757
gl.bindTexture(gl.TEXTURE_2D, texture);
5858

59-
const level = 0;
60-
const internalFormat = gl.RGBA;
61-
const srcFormat = gl.RGBA;
62-
const srcType = gl.UNSIGNED_BYTE;
59+
const internalFormat = gl.RGBA8;
60+
try {
61+
gl.texElementImage2D(gl.TEXTURE_2D, internalFormat, draw_element);
62+
} catch (e) {
63+
// The texElementImage2D API was recently changed (see:
64+
// https://github.com/WICG/html-in-canvas#idl-changes). This snippet
65+
// supports the old syntax temporarily so that the demos do not break.
66+
const level = 0;
67+
const srcFormat = gl.RGBA;
68+
const destType = gl.UNSIGNED_BYTE;
69+
gl.texElementImage2D(gl.TEXTURE_2D, level, internalFormat,
70+
srcFormat, destType, draw_element);
71+
console.log('Note: using old texElementImage2D API');
72+
}
6373

64-
gl.texElementImage2D(gl.TEXTURE_2D, level, internalFormat,
65-
srcFormat, srcType, draw_element);
6674

6775
// Linear texture filtering produces better results than mipmap with text.
6876
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);

0 commit comments

Comments
 (0)