Game Development Reference
In-Depth Information
// Step 3: Specify 3D model vertices
var vertices = [
0.0, 0.1, 0.0,
-1.0, -1.0, 0.0,
1.0, -1.0, 0.0
];
// Step 4: Fill the buffer with the data from
the model
gl.bufferData(gl.ARRAY_BUFFER, new
Float32Array(vertices),
gl.STATIC_DRAW);
// Step 5: Create some variables with
information about the
vertex buffer
// to simplify calculations later on
// Each vertex has an X, Y, Z component
buffer.itemSize = 3;
// There are 3 unique vertices
buffer.numItems = parseInt(vertices.length /
buffer.itemSize);
return buffer;
}
(function main() {
// ...
var triangleVertBuf = initTriangleBuffer(gl);
})();
After we have a shader program in place, which will tell the graphics card how to
draw whatever points we give it to draw for us, it follows that we now need a few
points to draw. Thus, this next step creates a buffer of points that we will draw in a
Search WWH ::




Custom Search