(
gl: WebGL2RenderingContext, texture: WebGLTexture,
dims: {width: number, height: number}, flipHorizontal: boolean,
rotation: Rotation)
| 149 | * @param dims texture size |
| 150 | */ |
| 151 | export function drawTexture( |
| 152 | gl: WebGL2RenderingContext, texture: WebGLTexture, |
| 153 | dims: {width: number, height: number}, flipHorizontal: boolean, |
| 154 | rotation: Rotation) { |
| 155 | const {program, vao, vertices, uniformLocations} = |
| 156 | drawTextureProgram(gl, flipHorizontal, false, rotation); |
| 157 | gl.useProgram(program); |
| 158 | gl.bindVertexArray(vao); |
| 159 | |
| 160 | // Set texture sampler uniform |
| 161 | const TEXTURE_UNIT = 0; |
| 162 | gl.uniform1i(uniformLocations.get('inputTexture'), TEXTURE_UNIT); |
| 163 | gl.activeTexture(gl.TEXTURE0 + TEXTURE_UNIT); |
| 164 | gl.bindTexture(gl.TEXTURE_2D, texture); |
| 165 | |
| 166 | // Draw to screen |
| 167 | gl.bindFramebuffer(gl.FRAMEBUFFER, null); |
| 168 | gl.viewport(0, 0, dims.width, dims.height); |
| 169 | // gl.clearColor(1, 1, 0, 1); |
| 170 | // gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); |
| 171 | gl.drawArrays(gl.TRIANGLES, 0, vertices.length / 2); |
| 172 | |
| 173 | gl.bindVertexArray(null); |
| 174 | gl.bindTexture(gl.TEXTURE_2D, null); |
| 175 | gl.useProgram(null); |
| 176 | } |
| 177 | |
| 178 | export function runResizeProgram( |
| 179 | gl: WebGL2RenderingContext, inputTexture: WebGLTexture, |
no test coverage detected
searching dependent graphs…