Buffer object handling is as before. However, we have a additional vertex attribute, used to represent texture coordinates.
The texture coordinate data must converted to a flat typed array.
new Float32Array(flatten(texCoords))And that array must be copied to an array buffer.
gl.createBuffer()gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer)gl.bufferData(gl.ARRAY_BUFFER, texCoordArray, gl.STATIC_DRAW)The GLSL program attribute location must be determined.
gl.getAttribLocation(program, “vertexTexCoord”)And finally, before rendering, the texture coordinate attribute pointer must be set and enabled.
gl.vertexAttribPointer(vertexTexCoordLocation, 2, gl.FLOAT, false, 0, 0)gl.enableVertexAttribArray(vertexTexCoordLocation)