UNB/ CS/ David Bremner/ teaching/ old/ cs4735/ JavaScript

Reference

Hints

Debugging output

Including Files

Embedding GLSL shaders in JavaScript

<script type="x-shader/x-vertex" id="vertShader">
attribute vec4 a_Position;
attribute vec4 a_Color;
uniform mat4 u_ViewMatrix;
varying vec4 v_Color; 
void main() {
  gl_Position =
    u_ViewMatrix * a_Position;
  v_Color = a_Color;
}
</script>

// Later in JavaScript
var vertShader = document.getElementById('vertShader').textContent;

JavaScript Objects

function Thing(msg) {
    this.message=msg;
}

Thing.prototype = {
    message: undefined,
    test : function() { print(this.message); }
}

var foo = new Thing();

var bar=new Thing("hi mom");

foo.test();
bar.test();

JS/WebGL Debugging

WebGL Debugging