02-drawingandshaders/scripts/demo02-02.js
/**
 * Initializes all variables, shaders, and WebGL options 
 * needed for this program.
 */
Initializes all variables, shaders, and WebGL options
needed for this program.
Initializes all variables shaders and WebGL options needed for this program .
function init() {
    gl.clearColor(1.0, 1.0, 1.0, 1.0);
    vbo = gl.createBuffer();
    indices = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
    var vertices = new Float32Array([ -0.5, -0.5, 0.0,      
                                       0.5, -0.5, 0.0,      
                                       0.0,  0.5, 0.0,      
                                       1.0,  0.0, 0.0, 1.0, 
                                       0.1,  0.3, 0.7, 1.0, 
                                       1.0,  1.0, 0.0, 1.0  
                                   ]);
    gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
    gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indices);
    gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array([0,1,2]), gl.STATIC_DRAW);
    initShaders();
}
function init ( ) { gl . clearColor ( 1.0 , 1.0 , 1.0 , 1.0 ) ; vbo = gl . createBuffer ( ) ; indices = gl . createBuffer ( ) ; gl . bindBuffer ( gl . ARRAY_BUFFER , vbo ) ; var vertices = new Float32Array ( [ - 0.5 , - 0.5 , 0.0 , 0.5 , - 0.5 , 0.0 , 0.0 , 0.5 , 0.0 , 1.0 , 0.0 , 0.0 , 1.0 , 0.1 , 0.3 , 0.7 , 1.0 , 1.0 , 1.0 , 0.0 , 1.0 ] ) ; gl . bufferData ( gl . ARRAY_BUFFER , vertices , gl . STATIC_DRAW ) ; gl . bindBuffer ( gl . ELEMENT_ARRAY_BUFFER , indices ) ; gl . bufferData ( gl . ELEMENT_ARRAY_BUFFER , new Uint16Array ( [ 0 , 1 , 2 ] ) , gl . STATIC_DRAW ) ; initShaders ( ) ; }
Initializes all variables, shaders, and WebGL options
 needed for this program.
Initializes all variables shaders and WebGL options needed for this program .
// Set the clear color to fully transparent black // Create the two buffer objects // Bind the vertex buffer object // Put 3 vertices of a triangle in the VBO // Position 1 // Position 2 // Position 3     // Color 1 - Red // Color 2 - Blue // Color 3 - Yellow // Bind and set the data of the lineIndices buffer // Initialize the shaders