this.gl = WebGLUtils.setupWebGL(canvas);
if (!this.gl) {
alert ("WebGL isn't available");
}
this.gl.viewport(0,0, width, height);
program = initShaders(this.gl, "vertex-shader","fragment-shader"); this.gl.useProgram(program);
var bufferID = this.gl.createBuffer(); this.gl.bindBuffer(this.gl.ARRAY_BUFFER, bufferID);
var vPosition = this.gl.getAttribLocation(program, "vPosition");
this.gl.vertexAttribPointer(vPosition,2,this.gl.FLOAT, false,0,0);
this.gl.enableVertexAttribArray(vPosition);
Init: function() {
this.list= [];
this.gl.clearColor(1.0, 1.0, 1.0, 1.0);
var p1 = vec2(this.width/2.0, this.height-20);
var p2 = vec2(20, 20);
var p3 = vec2(this.width-20, 20);
this.tri = [p1, p2, p3]
this.MakePoints();
var gl = this.gl;
this.gl.bufferData(gl.ARRAY_BUFFER,flatten(this.list),gl.STATIC_DRAW);
},
q = this.HalfPoint(p,v); tmp= add(q, [-this.width/2.0,-this.height/2.0]);
var scaleFactor = 2/Math.max(this.height, this.width); ... q = this.HalfPoint(p,v); tmp= add(q, [-this.width/2.0,-this.height/2.0]); tmp = scale(scaleFactor,tmp);
Redisplay: function() {
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
this.gl.drawArrays(this.gl.POINTS, 0, this.count);
return;
}