{"name":"gl-buffer","version":"2.0.8","description":"WebGL buffer wrapper","main":"buffer.js","directories":{"example":"example"},"dependencies":{"ndarray":"^1.0.15","typedarray-pool":"^1.0.0","ndarray-ops":"^1.1.0","webglew":"^1.0.0"},"devDependencies":{"gl-now":"^1.3.1","glslify":"^1.4.0"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1","start":"beefy --open example/example.js -- --transform glslify"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/gl-buffer.git"},"keywords":["webgl","buffer","vertex","array","element","array"],"author":{"name":"Mikola Lysenko"},"license":"MIT","gitHead":"fa00ce204834850a2a9118824aca293399bc3e4d","bugs":{"url":"https://github.com/mikolalysenko/gl-buffer/issues"},"homepage":"https://github.com/mikolalysenko/gl-buffer","_id":"gl-buffer@2.0.8","dist":{"shasum":"9ad9ef3f63ce134de49315e8ac3499cc548d9041","tarball":"http://registry-npm.ywwl.com/gl-buffer/download/gl-buffer-2.0.8.tgz","integrity":"sha512-8SHXeuLaV2WbWFVvuz4pcSqWvPgF6uPzpSP9GJdBAMWceJfR6DuHVRn6jqlHrE7H2onYouqz2InyUUNaECmRIw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCeVUsJ2WQuNmuJKgmocbGMeetDE4KSfz0s8uXAlU6WAQIgHU2vtq1iQADhBsF05HEc6bR7ymwTvqj9o1PUJtv2QpY="}],"size":124968,"noattachment":false,"key":"/gl-buffer/-/gl-buffer-2.0.8.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"readme":"gl-buffer\n=========\nA wrapper for WebGL buffer objects.\n\n# Example\n\n[View this demo in your browser](http://stack.gl/gl-buffer)\n\n```javascript\nvar shell = require(\"gl-now\")()\nvar glslify = require(\"glslify\")\nvar createBuffer = require(\"gl-buffer\")\n\nvar createShader = glslify({\n  vertex: \"\\\n    attribute vec2 position;\\\n    varying vec2 uv;\\\n    void main() {\\\n      gl_Position = vec4(position, 0.0, 1.0);\\\n      uv = position.xy;\\\n    }\",\n  fragment: \"\\\n    precision highp float;\\\n    uniform float tick;\\\n    varying vec2 uv;\\\n    void main() {\\\n      gl_FragColor = vec4(0.5*(uv+1.0), 0.5*(cos(tick)+1.0), 1.0);\\\n    }\",\n  inline: true\n})\n\nvar buffer, shader\n\nshell.on(\"gl-init\", function() {\n  var gl = shell.gl\n\n  //Create buffer\n  buffer = createBuffer(gl, [-1, 0, 0,-1, 1, 1])\n\n  //Create shader\n  shader = createShader(gl)\n  shader.attributes.position.location = 0\n})\n\nshell.on(\"gl-render\", function(t) {\n  var gl = shell.gl\n  shader.bind()\n  buffer.bind()\n  shader.attributes.position.pointer()\n  shader.uniforms.tick = Date.now() / 1000.0\n  gl.drawArrays(gl.TRIANGLES, 0, 3)\n})\n```\n\nOutput:\n\n<img src=\"http://stack.gl/gl-buffer/screenshot.png\">\n\n# Install\n\n    npm install gl-buffer\n\n# API\n\n```javascript\nvar createBuffer = require(\"gl-buffer\")\n```\n\n## Constructor\nThe constructor for a GL buffer works as follows:\n\n### `var buffer = createBuffer(gl[, data, type, usage])`\n\n* `gl` is a WebGL context\n* `data` is either an integer, an array, a typed array, an array buffer or an ndarray representing the data of the buffer.  Default is `0`\n* `type` is an optional parameter specifying the type of the webgl buffer.  Default is `gl.ARRAY_BUFFER`.\n* `usage` is an optional parameter representing the intended usage for the buffer (in the WebGL sense).  It is not clear this does anything in current WebGL implementations.  Default `gl.DYNAMIC_DRAW`\n\n## Properties\n\n### `buffer.gl`\nA reference to the buffer's WebGL context\n\n### `buffer.handle`\nA handle to the underlying WebGLBuffer object\n\n### `buffer.type`\nThe type of the buffer (either `gl.ARRAY_BUFFER` or `gl.ELEMENT_ARRAY_BUFFER`)\n\n### `buffer.length`\nThe size of the buffer in bytes\n\n### `buffer.usage`\nThe internal WebGL usage for the buffer.\n\n## Methods\n\n### `buffer.bind()`\nBinds the buffer to the appropriate target.  Equivalent to `gl.bindBuffer( ... )`\n\n### `buffer.dispose()`\nDeletes the buffer releasing all associated resources.  Equivalent to `gl.deleteBuffer(...)`\n\n### `buffer.update(data[, offset])`\nUpdates the data in the buffer. There are two basic modes to this function.  In the first, it calls `gl.bufferSubData` to update a portion of the buffer in place, and in the second it calls `gl.bufferData` to completely resize the buffer.\n\n* `data` the new data to add to the buffer.  This follows the same semantics as in the constructor.\n* `offset` the offset **in bytes** to copy data into the buffer from *or* if unspecified then the buffer is resized by calling `gl.bufferData` instead of `gl.bufferSubData`.  Default `0`.\n\n## Credits\n(c) 2013-2014 Mikola Lysenko. MIT License\n","publish_time":1402609582879,"_cnpm_publish_time":1402609582879,"dist-tags":{"latest":"2.1.2"}}