Below is the link where the files are updated to get the type attribute.
If you are looking for //ADDED CODE , you should be able to see all the changes I had to make to make it work.
In addition to including objectTypeAttribute you need to create an array buffer for each object you draw:
triangleObjectTypeBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, triangleObjectTypeBuffer); objectTypes = [ 1.0, 1.0, 0.0 ]; gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(objectTypes), gl.STATIC_DRAW); triangleObjectTypeBuffer.itemSize = 1; triangleObjectTypeBuffer.numItems = 3;
And bind this array buffer for each object before drawing the object:
gl.bindBuffer(gl.ARRAY_BUFFER, triangleObjectTypeBuffer); gl.vertexAttribPointer(shaderProgram.objectTypeAttribute, triangleObjectTypeBuffer.itemSize, gl.FLOAT, false, 0, 0);
You probably already tried this and accidentally made a mistake somewhere along the way.
source share