Skip to content

Commit

Permalink
Updated glquery and the glquery math module
Browse files Browse the repository at this point in the history
  • Loading branch information
rehno-lindeque committed Jan 20, 2012
1 parent 9a77002 commit 83b0ceb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/glquery/camera-0.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ register('camera-0','glquery', 'glQuery Camera',
.shaderProgram(shaderProgram)
.vertexAttrib('position', vbo, 9*8, gl.FLOAT, 3, false, 0, 0)
.vertexElem(ibo, 6*6, gl.UNSIGNED_SHORT, 0)
.uniform('view', gl.setMatrix4LookAt([10.0,10.0,10.0], [0.0,0.0,0.0], [0.0,1.0,0.0]))
//.uniform('view', gl.setMatrix4Identity())
.uniform('projection', gl.setMatrix4Ortho(-1.0, 1.0, -1.0, 1.0, 0.1, 100.0))
//.uniform('projection', gl.setMatrix4Identity())
.uniform('view', gl.matrix4.newLookAt([10.0,10.0,10.0], [0.0,0.0,0.0], [0.0,1.0,0.0]))
//.uniform('view', gl.matrix4.newIdentity())
.uniform('projection', gl.matrix4.newOrtho(-1.0, 1.0, -1.0, 1.0, 0.1, 100.0))
//.uniform('projection', gl.matrix4.newIdentity())
.triangles()
.render(context);

console.log(gl.setMatrix4LookAt([10.0,10.0,10.0], [0.0,0.0,0.0], [0.0,1.0,0.0]));
console.log(gl.setMatrix4Ortho(-1.0, 1.0, -1.0, 1.0, 0.1, 100.0));
console.log(gl.matrix4.newLookAt([10.0,10.0,10.0], [0.0,0.0,0.0], [0.0,1.0,0.0]));
console.log(gl.matrix4.newOrtho(-1.0, 1.0, -1.0, 1.0, 0.1, 100.0));
}
);
6 changes: 6 additions & 0 deletions static/lib/glquery/glquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,12 @@ var glQuery = (function() {
return commands.length > 0;
};

gl.refresh = function(obj) {
if (obj instanceof WebGLProgram && obj['_glquery_id'] != null) {
shaderLocations[obj._glquery_id] = {};
}
};

// Utility functions for working with tags
// Test whether t0 contains any of the tags in ts1
var containsAnyTags = function(t0, ts1) {
Expand Down
20 changes: 11 additions & 9 deletions static/lib/glquery/glquery.math.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ glQueryMath.vec4.length = function(a) {
return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3]);
};

glQueryMath.matrix3 = {};
// Module for setting 3x3 matrix values

// Axis-angle rotation matrix using the right hand rule
glQueryMath.setMatrix3AxisRotation = function(axis, angle) {
glQueryMath.matrix3.newAxisRotation = function(axis, angle) {
var
// Convert rotation to quaternion representation
length = Math.sqrt(axis[0]*axis[0], axis[1]*axis[1], axis[2]*axis[2]),
Expand All @@ -147,17 +148,18 @@ glQueryMath.setMatrix3AxisRotation = function(axis, angle) {
};

// Matrix identity
glQueryMath.setMatrix3Identity = function() {
glQueryMath.matrix3.newIdentity = function() {
return [
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0];
};

glQueryMath.matrix4 = {};
// Module for setting 4x4 matrix values

// Axis-angle rotation matrix using the right hand rule
glQueryMath.setMatrix4AxisRotation = function(axis, angle) {
glQueryMath.matrix4.newAxisRotation = function(axis, angle) {
var
// Convert rotation to quaternion representation
length = Math.sqrt(axis[0]*axis[0], axis[1]*axis[1], axis[2]*axis[2]),
Expand All @@ -179,19 +181,19 @@ glQueryMath.setMatrix4AxisRotation = function(axis, angle) {
};

// Matrix identity
glQueryMath.setMatrix4Identity = function() {
glQueryMath.matrix4.newIdentity = function() {
return [
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0];
};

glQueryMath.setMatrix4Rows = function(r0, r1, r2, r3) {
glQueryMath.matrix4.newRows = function(r0, r1, r2, r3) {
return [].concat(r0, r1, r2, r3);
}

glQueryMath.setMatrix4Columns = function(c0, c1, c2, c3) {
glQueryMath.matrix4.newColumns = function(c0, c1, c2, c3) {
return [
c0[0], c1[0], c2[0],c3[0],
c0[1], c1[1], c2[1],c3[1],
Expand All @@ -201,7 +203,7 @@ glQueryMath.setMatrix4Columns = function(c0, c1, c2, c3) {
}

// Right-handed orthogonal projection matrix
glQueryMath.setMatrix4Ortho = function(left, right, bottom, top, near, far) {
glQueryMath.matrix4.newOrtho = function(left, right, bottom, top, near, far) {
var x = left - right,
y = bottom - top,
z = near - far;
Expand All @@ -214,7 +216,7 @@ glQueryMath.setMatrix4Ortho = function(left, right, bottom, top, near, far) {
};

// Right-handed look-at matrix
glQueryMath.setMatrix4LookAt = function(eye, target, up) {
glQueryMath.matrix4.newLookAt = function(eye, target, up) {
// TODO: See if it would be more efficient to try and build the matrix
// by rows instead of by columns as is done presently
var x = MathMemoryPool.vector4[0],
Expand All @@ -239,7 +241,7 @@ glQueryMath.setMatrix4LookAt = function(eye, target, up) {
w[1] = 0.0;
w[2] = 0.0;
w[3] = 1.0;
return glQueryMath.setMatrix4Columns(x,y,z,w);
return glQueryMath.matrix4.newColumns(x,y,z,w);
};

// Extend glQuery if it is defined
Expand Down
2 changes: 1 addition & 1 deletion static/lib/glquery/glquery.math.module.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 83b0ceb

Please sign in to comment.