var gl;

window.onload = function init()
{
    // Get canvas and setup webGL
    
    var canvas = document.getElementById("gl-canvas");
    gl = WebGLUtils.setupWebGL(canvas);
    if (!gl) { alert("WebGL isn't available"); }

    // Specify position and color of the vertices
    
    var vertices = new Float32Array([
                                    0.0, 0.5, // x0, y0
                                       0.04,  0.5  // x1, y1
                                    ]);
    var colors = new Float32Array([ 1, 1, 1, 1, 
                                    1, 1, 1, 1]);
    
    // Configure viewport

    gl.viewport(0,0,canvas.width,canvas.height);
    gl.clearColor(0,0,0,1.0);

    // Init shader program and bind it

    var program = initShaders(gl, "vertex-shader", "fragment-shader");

    gl.useProgram(program);
    
    // Load colors into the GPU and associate shader variables
    
    var cBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, cBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
    
    var vColor = gl.getAttribLocation(program, "vColor");
    gl.vertexAttribPointer(vColor, 4, gl.FLOAT, false, 0, 0);
    gl.enableVertexAttribArray(vColor);

    // Load positions into the GPU and associate shader variables

    var bufferId = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, bufferId);
    gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);

    var vPosition = gl.getAttribLocation(program, "vPosition");
    gl.vertexAttribPointer(vPosition, 2, gl.FLOAT, false, 0, 0);
    gl.enableVertexAttribArray(vPosition);
    
    render();
};

function render()
{
    gl.clear(gl.COLOR_BUFFER_BIT);
    gl.drawArrays(gl.POINTS, 0, 2);
}

@@ -1704,8 +1704,229 @@
 , 2);%0A%7D%0A
+%0A// normValue(256, 0, 512, -1, 1) -%3E 0%0Afunction normValue(value, valueMin, valueMax, resultMin, resultMax)%0A%7B%0A    temp = (value - valueMin) / (valueMax - valueMin);%0A    return temp * (resultMax - resultMin) + resultMin;%0A%7D%0A

add function discussed in exercise