Just repeat the part that buffers the vertex data and draws the triangles.
166 // Here we create and compile the vertex shader. This will compile to code for your specific 167 // graphics card. 168 var vertexShader = compileShader(gl, vertexShaderSource, gl.VERTEX_SHADER); 169 170 // And then compile the fragment shader too. 171 var fragmentShader = compileShader(gl, fragmentShaderSource, gl.FRAGMENT_SHADER); 172 173 // As you might expect, we are going to run some code, so we need a program. 174 var program = createProgram(gl, vertexShader, fragmentShader); 175 176 // Make this the currently active program 177 gl.useProgram(program); 178 179 // This is a handle to what will be a buffer 180 var vertexBuffer = createBuffer(vertices); 181 182 // Bind the buffer to the positon attribute 183 bindBuffer(vertexBuffer, 'position', 3, gl.FLOAT, 28, 0); 184 185 // And to the color attribute 186 bindBuffer(vertexBuffer, 'color', 4, gl.FLOAT, 28, 12); 187 188 // Finally run the program. Render, or draw, the data. Here we tell it to draw triangles starting 189 // with element zero of the vertexBuffer, and that there are three vertices. So there is 190 // one triangle. 191 gl.drawArrays(gl.TRIANGLES, 0, 3); 192 193 194 // Repeat the same process again, create another buffer with different vertices and draw them. 195 var anotherBuffer = createBuffer(moreVertices); 196 197 // Bind the buffer to the positon attribute 198 bindBuffer(anotherBuffer, 'position', 3, gl.FLOAT, 28, 0); 199 200 // And to the color attribute 201 bindBuffer(anotherBuffer, 'color', 4, gl.FLOAT, 28, 12); 202 203 // Finally run the program. Render, or draw, the data. Here we tell it to draw triangles starting 204 // with element zero of the buffer, and that there are three vertices. So there is 205 // one triangle. 206 gl.drawArrays(gl.TRIANGLES, 0, 3);
Lines 179-191 draw the first triangle, and lines 194-206 draw the second triangle.