Skip to content

Commit

Permalink
reflect changes for KhronosGroup#96
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrobinet committed Oct 16, 2013
1 parent 5c085ba commit 12141ca
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 258 deletions.
13 changes: 8 additions & 5 deletions runtime/glsl-program.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,13 @@ var GLSLProgram = exports.GLSLProgram = Object.create(Object.prototype, {
var existingValue = this.symbolToValue[symbol];
var type = this.getTypeForSymbol(symbol);
var GL = this._GLTypes;

if (( value != null) && (existingValue != null)) {
if (type === GL.FLOAT) {
if (value === existingValue) {
return;
}
}

if (type === GL.FLOAT_MAT4) {
} else if (type === GL.FLOAT_MAT4) {
if (value.length == 16) {
if (mat4.equal(existingValue, value)) {
return;
Expand Down Expand Up @@ -337,7 +336,9 @@ var GLSLProgram = exports.GLSLProgram = Object.create(Object.prototype, {

} else {
if (type === GL.FLOAT_MAT4) {
existingValue = mat4.create();
if (value.length === 16) {
existingValue = mat4.create();
}
} else if (type === GL.FLOAT_MAT3) {
existingValue = mat3.create();
} else if (type === GL.FLOAT_VEC3) {
Expand All @@ -357,7 +358,9 @@ var GLSLProgram = exports.GLSLProgram = Object.create(Object.prototype, {

if (value != null) {
if (type === GL.FLOAT_MAT4) {
value = mat4.set(value ,existingValue);
if (value.length === 16) {
value = mat4.set(value ,existingValue);
}
} else if (type === GL.FLOAT_MAT3) {
value = mat3.set(value, existingValue);
} else if (type === GL.FLOAT_VEC3) {
Expand Down
16 changes: 8 additions & 8 deletions runtime/helpers/resource-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,21 +744,21 @@ var global = window;
_elementSizeForGLType: {
value: function(glType) {
switch (glType) {
case "FLOAT" :
case WebGLRenderingContext.FLOAT :
return Float32Array.BYTES_PER_ELEMENT;
case "UNSIGNED_BYTE" :
case WebGLRenderingContext.UNSIGNED_BYTE:
return Uint8Array.BYTES_PER_ELEMENT;
case "UNSIGNED_SHORT" :
case WebGLRenderingContext.UNSIGNED_SHORT:
return Uint16Array.BYTES_PER_ELEMENT;
case "FLOAT_VEC2" :
case WebGLRenderingContext.FLOAT_VEC2:
return Float32Array.BYTES_PER_ELEMENT * 2;
case "FLOAT_VEC3" :
case WebGLRenderingContext.FLOAT_VEC3:
return Float32Array.BYTES_PER_ELEMENT * 3;
case "FLOAT_VEC4" :
case WebGLRenderingContext.FLOAT_VEC4:
return Float32Array.BYTES_PER_ELEMENT * 4;
case "FLOAT_MAT4" :
case WebGLRenderingContext.FLOAT_MAT4:
return Float32Array.BYTES_PER_ELEMENT * 16;
case "FLOAT_MAT3" :
case WebGLRenderingContext.FLOAT_MAT3:
return Float32Array.BYTES_PER_ELEMENT * 9;
default:
return null;
Expand Down
12 changes: 6 additions & 6 deletions runtime/runtime-tf-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ exports.RuntimeTFLoader = Object.create(glTFParser, {
if (parameter) {
var paramValue = null;
switch (parameter.type) {
case "SAMPLER_CUBE":
case "SAMPLER_2D":
case WebGLRenderingContext.SAMPLER_CUBE:
case WebGLRenderingContext.SAMPLER_2D:
{
var entry = this.getEntry(value.value);
if (entry) {
Expand Down Expand Up @@ -569,16 +569,16 @@ exports.RuntimeTFLoader = Object.create(glTFParser, {
var parameterDescription = description.parameters[parameterSID];
//we can avoid code below if we add byteStride
switch (parameterDescription.type) {
case "FLOAT_VEC4":
case WebGLRenderingContext.FLOAT_VEC4:
componentsPerAttribute = 4;
break;
case "FLOAT_VEC3":
case WebGLRenderingContext.FLOAT_VEC3:
componentsPerAttribute = 3;
break;
case "FLOAT_VEC2":
case WebGLRenderingContext.FLOAT_VEC2:
componentsPerAttribute = 2;
break;
case "FLOAT":
case WebGLRenderingContext.FLOAT:
componentsPerAttribute = 1;
break;
default: {
Expand Down
Loading

0 comments on commit 12141ca

Please sign in to comment.