| 67 | |
| 68 | // Utility class for drawing. |
| 69 | class FullscreenQuad { |
| 70 | constructor(gl) { |
| 71 | this.squareVerticesBuffer_ = gl.createBuffer(); |
| 72 | gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVerticesBuffer_); |
| 73 | gl.bufferData( |
| 74 | gl.ARRAY_BUFFER, Float32Array.from([-1, -1, 1, -1, -1, 1, 1, 1]), |
| 75 | gl.STATIC_DRAW); |
| 76 | |
| 77 | this.textureVerticesBuffer_ = gl.createBuffer(); |
| 78 | gl.bindBuffer(gl.ARRAY_BUFFER, this.textureVerticesBuffer_); |
| 79 | gl.bufferData( |
| 80 | gl.ARRAY_BUFFER, Float32Array.from([0, 0, 1, 0, 0, 1, 1, 1]), |
| 81 | gl.STATIC_DRAW); |
| 82 | |
| 83 | this.gl_ = gl; |
| 84 | } |
| 85 | |
| 86 | // Draws a quad covering the entire bound framebuffer. |
| 87 | draw() { |
| 88 | this.gl_.enableVertexAttribArray(0); // vertex |
| 89 | this.gl_.bindBuffer(this.gl_.ARRAY_BUFFER, this.squareVerticesBuffer_); |
| 90 | this.gl_.vertexAttribPointer(0, 2, this.gl_.FLOAT, false, 0, 0); |
| 91 | |
| 92 | this.gl_.enableVertexAttribArray(1); |
| 93 | this.gl_.bindBuffer(this.gl_.ARRAY_BUFFER, this.textureVerticesBuffer_); |
| 94 | this.gl_.vertexAttribPointer(1, 2, this.gl_.FLOAT, false, 0, 0); |
| 95 | |
| 96 | this.gl_.drawArrays(this.gl_.TRIANGLE_STRIP, 0, 4); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // Utility class for processing a shader. |
| 101 | class GlShaderProcessor { |
nothing calls this directly
no outgoing calls
no test coverage detected