Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var pool = require("typedarray-pool")
var ops = require("ndarray-ops")
var ndarray = require("ndarray")
var webglew = require("webglew")

var SUPPORTED_TYPES = [
"uint8",
Expand Down Expand Up @@ -38,7 +37,7 @@ proto.dispose = function() {
}

function updateTypeArray(gl, type, len, usage, data, offset) {
var dataLen = data.length * data.BYTES_PER_ELEMENT
var dataLen = data.length * data.BYTES_PER_ELEMENT
if(offset < 0) {
gl.bufferData(type, data, usage)
return dataLen
Expand Down Expand Up @@ -81,8 +80,7 @@ proto.update = function(array, offset) {
dtype = "float32"
}
if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) {
var wgl = webglew(this.gl)
var ext = wgl.OES_element_index_uint
var ext = gl.getExtension('OES_element_index_uint')
if(ext && dtype !== "uint16") {
dtype = "uint32"
} else {
Expand All @@ -100,9 +98,9 @@ proto.update = function(array, offset) {
var ndt = ndarray(tmp, array.shape)
ops.assign(ndt, array)
if(offset < 0) {
this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp, offset)
this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp, offset)
} else {
this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp.subarray(0, array.size), offset)
this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp.subarray(0, array.size), offset)
}
pool.free(tmp)
}
Expand Down Expand Up @@ -137,7 +135,6 @@ proto.update = function(array, offset) {
}

function createBuffer(gl, data, type, usage) {
webglew(gl)
type = type || gl.ARRAY_BUFFER
usage = usage || gl.DYNAMIC_DRAW
if(type !== gl.ARRAY_BUFFER && type !== gl.ELEMENT_ARRAY_BUFFER) {
Expand All @@ -152,4 +149,4 @@ function createBuffer(gl, data, type, usage) {
return result
}

module.exports = createBuffer
module.exports = createBuffer
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"dependencies": {
"ndarray": "^1.0.15",
"typedarray-pool": "^1.0.0",
"ndarray-ops": "^1.1.0",
"webglew": "^1.0.0"
"ndarray-ops": "^1.1.0"
},
"devDependencies": {
"gl-now": "^1.3.1",
Expand Down