Skip to content

Lower level

createProgram() ​

ts
function createProgram(
   gl, 
   vertexSrc, 
   fragmentSrc, 
   attribs?
): WebGLProgram;

Defined in: createProgram.js:17

Compiles both shaders and attaches them to a new program. The program is returned unlinked so attribute locations can be bound first; call linkProgram before using it.

Parameters ​

ParameterTypeDescription
glWebGL2RenderingContextThe WebGL2 context.
vertexSrcstringGLSL ES 3.00 vertex shader source.
fragmentSrcstringGLSL ES 3.00 fragment shader source.
attribs?Record<string, Attribute>Attributes whose varyings, for transform feedback attributes, are captured from the vertex shader.

Returns ​

WebGLProgram