MCPcopy Index your code
hub / github.com/tensorflow/tfjs / drawTexture

Function drawTexture

tfjs-react-native/src/camera/camera_webgl_util.ts:151–176  ·  view source on GitHub ↗
(
    gl: WebGL2RenderingContext, texture: WebGLTexture,
    dims: {width: number, height: number}, flipHorizontal: boolean,
    rotation: Rotation)

Source from the content-addressed store, hash-verified

149 * @param dims texture size
150 */
151export 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
178export function runResizeProgram(
179 gl: WebGL2RenderingContext, inputTexture: WebGLTexture,

Callers 1

renderToGLViewFunction · 0.90

Calls 2

drawTextureProgramFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…