@hscmap/gl-wrapper
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -21,2 +21,3 @@ import { Program } from './program'; | ||
private usage; | ||
private bufferSize; | ||
vertexCount: number; | ||
@@ -23,0 +24,0 @@ constructor(gl: WebGLRenderingContext, data?: DataOption); |
@@ -7,2 +7,4 @@ "use strict"; | ||
this.gl = gl; | ||
this.usage = -1; | ||
this.bufferSize = -1; | ||
this.vertexCount = 0; | ||
@@ -34,5 +36,7 @@ this.bufferName = glUtils.nonNull(gl.createBuffer()); | ||
if (array) { | ||
var vertexCount = byteLength(array) / this.stride; | ||
this.vertexCount = byteLength(array) / this.stride; | ||
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.bufferName); | ||
if (usage != this.usage || this.vertexCount != vertexCount) { | ||
if (usage != this.usage || this.bufferSize < this.vertexCount) { | ||
this.usage = usage; | ||
this.bufferSize = this.vertexCount; | ||
this.gl.bufferData(this.gl.ARRAY_BUFFER, array, usage); | ||
@@ -44,4 +48,2 @@ } | ||
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null); | ||
this.usage = usage; | ||
this.vertexCount = vertexCount; | ||
if (this.vertexCount % 1 !== 0) { | ||
@@ -48,0 +50,0 @@ throw "nComponents may be invalid"; |
{ | ||
"name": "@hscmap/gl-wrapper", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts", |
166741
5152