MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / createProgram

Function createProgram

gpu-pipeline/webgl/gl-util.js:133–152  ·  view source on GitHub ↗
(gl, vertexSrc, fragmentSrc)

Source from the content-addressed store, hash-verified

131
132 // Returns a wrapper class with a WebGL program and its util functions.
133 function createProgram(gl, vertexSrc, fragmentSrc) {
134 const vertexShader = compileShader(gl, gl.VERTEX_SHADER, vertexSrc);
135 checkGlError(gl, 'Compile vertex shader');
136
137 const fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSrc);
138 checkGlError(gl, 'Compile fragment shader');
139
140 const program = gl.createProgram();
141 gl.attachShader(program, vertexShader);
142 gl.attachShader(program, fragmentShader);
143
144 gl.bindAttribLocation(program, 0, 'position');
145 gl.bindAttribLocation(program, 1, 'input_tex_coord');
146 gl.linkProgram(program);
147 gl.useProgram(program);
148
149 checkGlError(gl, 'createProgram');
150
151 return new GlProgramImpl(gl, program);
152 }

Callers 1

constructorMethod · 0.85

Calls 3

compileShaderFunction · 0.85
checkGlErrorFunction · 0.85
useProgramMethod · 0.80

Tested by

no test coverage detected