From 160f359dd43305f2b4eb5fb3f9c6d9b14af0917f Mon Sep 17 00:00:00 2001 From: Mitch Skinner Date: Sat, 1 Mar 2014 14:06:23 -0800 Subject: [PATCH] add bufferSubData to Attribute, rebuild --- build/GLOW.js | 5 +++-- build/custom/GLOWCore.js | 13 +++++++++++++ src/core/Attribute.js | 13 +++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/build/GLOW.js b/build/GLOW.js index 967e635..7c7a435 100644 --- a/build/GLOW.js +++ b/build/GLOW.js @@ -80,8 +80,9 @@ this.data.updateTexture(this.data.autoUpdate))};f[GL.SAMPLER_CUBE]=function(){th a.length;this.type=a.type;this.location=a.location;this.locationNumber=a.locationNumber;this.textureUnit=a.textureUnit!==void 0?a.textureUnit:-1;this.load=a.loadFunction||f[this.type]}var c=!1,f=[];a.prototype.getNativeValue=function(){return this.data.value};a.prototype.clone=function(a){return new GLOW.Uniform(this,a||this.data)};a.prototype.dispose=function(a){this.data!==void 0&&this.type===GL.SAMPLER_2D&&a&&this.data.dispose();delete this.data;delete this.load;delete this.location};return a}(); GLOW.Attribute=function(){function b(b,e,h,g){a||(a=!0,c[GL.INT]=1,c[GL.INT_VEC2]=2,c[GL.INT_VEC3]=3,c[GL.INT_VEC4]=4,c[GL.BOOL]=1,c[GL.BOOL_VEC2]=2,c[GL.BOOL_VEC3]=3,c[GL.BOOL_VEC4]=4,c[GL.FLOAT]=1,c[GL.FLOAT_VEC2]=2,c[GL.FLOAT_VEC3]=3,c[GL.FLOAT_VEC4]=4,c[GL.FLOAT_MAT2]=4,c[GL.FLOAT_MAT3]=9,c[GL.FLOAT_MAT4]=16);this.id=GLOW.uniqueId();this.data=e;this.location=b.location;this.locationNumber=b.locationNumber;this.offset=this.stride=0;this.usage=h!==void 0?h:GL.STATIC_DRAW;this.interleaved=g!==void 0? g:!1;this.size=c[b.type];this.name=b.name;this.type=b.type;this.data&&(this.data.length/this.size>65536&&GLOW.warn("GLOW.Attribute.constructor: Unreachable attribute? Please activate GL.drawArrays or split into multiple shaders. Indexed elements cannot reach attribute data beyond 65535."),this.interleaved===!1&&this.bufferData(this.data,this.usage))}var a=!1,c=[];b.prototype.setupInterleave=function(a,b){this.interleaved=!0;this.offset=a;this.stride=b};b.prototype.bufferData=function(a,b){if(a!== -void 0&&this.data!==a)this.data=a;if(b!==void 0&&this.usage!==b)this.usage=b;if(this.buffer===void 0)this.buffer=GL.createBuffer();if(this.data.constructor.toString().indexOf(" Array()")!==-1)this.data=new Float32Array(this.data);GL.bindBuffer(GL.ARRAY_BUFFER,this.buffer);GL.bufferData(GL.ARRAY_BUFFER,this.data,this.usage)};b.prototype.bind=function(){this.interleaved===!1&&GL.bindBuffer(GL.ARRAY_BUFFER,this.buffer);GL.vertexAttribPointer(this.location,this.size,GL.FLOAT,!1,this.stride,this.offset)}; -b.prototype.clone=function(a){if(this.interleaved)GLOW.error("GLOW.Attribute.clone: Cannot clone interleaved attribute. Please check your interleave setup.");else return a=a||{},new GLOW.Attribute(this,a.data||this.data,a.usage||this.usage,a.interleaved||this.interleaved)};b.prototype.dispose=function(){this.buffer&&(GL.deleteBuffer(this.buffer),delete this.buffer);delete this.data};return b}(); +void 0&&this.data!==a)this.data=a;if(b!==void 0&&this.usage!==b)this.usage=b;if(this.buffer===void 0)this.buffer=GL.createBuffer();if(this.data.constructor.toString().indexOf(" Array()")!==-1)this.data=new Float32Array(this.data);GL.bindBuffer(GL.ARRAY_BUFFER,this.buffer);GL.bufferData(GL.ARRAY_BUFFER,this.data,this.usage)};b.prototype.bufferSubData=function(a,b){b===void 0&&(b=0);this.buffer===void 0&&GLOW.error("GLOWAttribute.prototype.bufferSubData: call bufferData first");a.constructor.toString().indexOf(" Array()")!== +-1&&(a=new Float32Array(a));GL.bindBuffer(GL.ARRAY_BUFFER,this.buffer);GL.bufferSubData(GL.ARRAY_BUFFER,b,a)};b.prototype.bind=function(){this.interleaved===!1&&GL.bindBuffer(GL.ARRAY_BUFFER,this.buffer);GL.vertexAttribPointer(this.location,this.size,GL.FLOAT,!1,this.stride,this.offset)};b.prototype.clone=function(a){if(this.interleaved)GLOW.error("GLOW.Attribute.clone: Cannot clone interleaved attribute. Please check your interleave setup.");else return a=a||{},new GLOW.Attribute(this,a.data||this.data, +a.usage||this.usage,a.interleaved||this.interleaved)};b.prototype.dispose=function(){this.buffer&&(GL.deleteBuffer(this.buffer),delete this.buffer);delete this.data};return b}(); GLOW.InterleavedAttributes=function(){function b(a){this.id=GLOW.uniqueId();this.attributes=a;var b,f=a[0].data.length/a[0].size,e,h=a.length,g,i,j,k=[],l,m=[];for(e=0;e