|
56 | 56 | const texture = gl.createTexture(); |
57 | 57 | gl.bindTexture(gl.TEXTURE_2D, texture); |
58 | 58 |
|
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 | + } |
63 | 73 |
|
64 | | - gl.texElementImage2D(gl.TEXTURE_2D, level, internalFormat, |
65 | | - srcFormat, srcType, draw_element); |
66 | 74 |
|
67 | 75 | // Linear texture filtering produces better results than mipmap with text. |
68 | 76 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); |
|
0 commit comments