Skip to content

Commit

Permalink
add bufferSubData to Attribute, rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
skinner committed Mar 1, 2014
1 parent 42ff852 commit 160f359
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
5 changes: 3 additions & 2 deletions build/GLOW.js

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

13 changes: 13 additions & 0 deletions build/custom/GLOWCore.js
Expand Up @@ -2093,6 +2093,19 @@ GLOW.Attribute = (function() {
GL.bufferData( GL.ARRAY_BUFFER, this.data, this.usage );
};

GLOWAttribute.prototype.bufferSubData = function( data, offset ) {
if( offset === undefined ) offset = 0;
if( this.buffer === undefined ) {
GLOW.error( "GLOWAttribute.prototype.bufferSubData: call bufferData first" );
}
if( data.constructor.toString().indexOf( " Array()") !== -1 ) {
data = new Float32Array( data );
}

GL.bindBuffer( GL.ARRAY_BUFFER, this.buffer );
GL.bufferSubData( GL.ARRAY_BUFFER, offset, data );
};

GLOWAttribute.prototype.bind = function() {
if( this.interleaved === false ) {
GL.bindBuffer( GL.ARRAY_BUFFER, this.buffer );
Expand Down
13 changes: 13 additions & 0 deletions src/core/Attribute.js
Expand Up @@ -74,6 +74,19 @@ GLOW.Attribute = (function() {
GL.bufferData( GL.ARRAY_BUFFER, this.data, this.usage );
};

GLOWAttribute.prototype.bufferSubData = function( data, offset ) {
if( offset === undefined ) offset = 0;
if( this.buffer === undefined ) {
GLOW.error( "GLOWAttribute.prototype.bufferSubData: call bufferData first" );
}
if( data.constructor.toString().indexOf( " Array()") !== -1 ) {
data = new Float32Array( data );
}

GL.bindBuffer( GL.ARRAY_BUFFER, this.buffer );
GL.bufferSubData( GL.ARRAY_BUFFER, offset, data );
};

GLOWAttribute.prototype.bind = function() {
if( this.interleaved === false ) {
GL.bindBuffer( GL.ARRAY_BUFFER, this.buffer );
Expand Down

0 comments on commit 160f359

Please sign in to comment.