Created
June 1, 2015 21:50
-
-
Save tmcw/2291cf3f3789bfb1112c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Lazy-create Int16Array objects for any buffer size | |
* @param {number} extent buffer extent: by default 4096. | |
* @returns {Int16Array} extent buffer | |
*/ | |
module.exports.getDebugBuffer = function getDebugBuffer(gl, extent) { | |
if (!debugBuffers[extent]) { | |
var debugBuffer = gl.createBuffer(); | |
debugBuffer.itemSize = 2; | |
debugBuffer.itemCount = 5; | |
gl.bindBuffer(gl.ARRAY_BUFFER, this.debugBuffer); | |
gl.bufferData(gl.ARRAY_BUFFER, new Int16Array([ | |
0, 0, extent - 1, 0, extent - 1, extent - 1, 0, extent - 1, 0, 0])); | |
debugBuffers[extent] = debugBuffer; | |
} | |
return debugBuffers[extent]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment