{"id":20778053,"url":"https://github.com/stackgl/gl-buffer","last_synced_at":"2025-04-30T18:40:51.203Z","repository":{"id":9036392,"uuid":"10798023","full_name":"stackgl/gl-buffer","owner":"stackgl","description":"WebGL buffer wrapper","archived":false,"fork":false,"pushed_at":"2015-06-11T05:39:54.000Z","size":506,"stargazers_count":23,"open_issues_count":2,"forks_count":6,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-14T19:06:39.142Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://stack.gl/gl-buffer","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackgl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-19T15:53:50.000Z","updated_at":"2023-02-21T17:18:12.000Z","dependencies_parsed_at":"2022-09-01T10:10:37.443Z","dependency_job_id":null,"html_url":"https://github.com/stackgl/gl-buffer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-buffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-buffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-buffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-buffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackgl","download_url":"https://codeload.github.com/stackgl/gl-buffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251764407,"owners_count":21640055,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T13:18:53.904Z","updated_at":"2025-04-30T18:40:51.160Z","avatar_url":"https://github.com/stackgl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"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\u003cimg src=\"http://stack.gl/gl-buffer/screenshot.png\"\u003e\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fgl-buffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackgl%2Fgl-buffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fgl-buffer/lists"}