{"id":20778033,"url":"https://github.com/stackgl/gl-vao","last_synced_at":"2025-07-27T02:34:45.609Z","repository":{"id":9079961,"uuid":"10853801","full_name":"stackgl/gl-vao","owner":"stackgl","description":"Vertex array object wrapper for WebGL","archived":false,"fork":false,"pushed_at":"2018-11-23T19:43:59.000Z","size":359,"stargazers_count":26,"open_issues_count":4,"forks_count":4,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-07-04T16:15:40.709Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://stack.gl/gl-vao/","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-21T22:14:06.000Z","updated_at":"2025-05-17T13:05:50.000Z","dependencies_parsed_at":"2022-09-06T08:10:21.200Z","dependency_job_id":null,"html_url":"https://github.com/stackgl/gl-vao","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/stackgl/gl-vao","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-vao","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-vao/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-vao/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-vao/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackgl","download_url":"https://codeload.github.com/stackgl/gl-vao/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-vao/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267289426,"owners_count":24064727,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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:42.462Z","updated_at":"2025-07-27T02:34:45.593Z","avatar_url":"https://github.com/stackgl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"gl-vao\n======\nWebGL vertex array object wrapper/polyfill\n\n## Example\n\n[Try out the demo in your browser](http://stack.gl/gl-vao/)\n\n```javascript\nvar shell = require(\"gl-now\")()\nvar createBuffer = require(\"gl-buffer\")\nvar createVAO = require(\"gl-vao\")\nvar glslify = require(\"glslify\")\nvar createShader = require(\"gl-shader\")\n\nvar vao, shader\n\nshell.on(\"gl-init\", function() {\n  var gl = shell.gl\n\n  //Create shader object\n  shader = createShader(gl,\n    glslify(\"\\\n      attribute vec2 position;\\\n      attribute vec3 color;\\\n      varying vec3 fragColor;\\\n      void main() {\\\n        gl_Position = vec4(position, 0, 1.0);\\\n        fragColor = color;\\\n      }\"\n      , {inline: true}\n    ),\n    glslify(\"\\\n      precision highp float;\\\n      varying vec3 fragColor;\\\n      void main() {\\\n        gl_FragColor = vec4(fragColor, 1.0);\\\n      }\"\n      , {inline: true}\n    )\n  );\n  shader.attributes.position.location = 0\n  shader.attributes.color.location = 1\n\n  //Create vertex array object\n  vao = createVAO(gl, [\n    { \"buffer\": createBuffer(gl, [-1, 0, 0, -1, 1, 1]),\n      \"type\": gl.FLOAT,\n      \"size\": 2\n    },\n    [0.8, 1, 0.5]\n  ])\n})\n\nshell.on(\"gl-render\", function(t) {\n  var gl = shell.gl\n\n  //Bind the shader\n  shader.bind()\n\n  //Bind vertex array object and draw it\n  vao.bind()\n  vao.draw(gl.TRIANGLES, 3)\n\n  //Unbind vertex array when fini\n  vao.unbind()\n})\n```\n\nAssuming everything worked, here is what it should look like:\n\n\u003cimg src=\"http://stackgl.github.io/gl-vao/screenshot.png\"\u003e\n\n## Install\n\nUse [npm](https://npmjs.org/):\n\n    npm install gl-vao\n    \nTo compile demos in for your browser try [browserify](https://github.com/substack/node-browserify) or [beefy](https://github.com/chrisdickinson/beefy).\n\n## API\n\n```javascript\nvar createVAO = require(\"gl-vao\")\n```\n\n### `var vao = createVAO(gl, attributes[, elements][, elementsType])`\nCreates a vertex array object\n\n* `gl` is the gl context in which the vertex array object is created\n* `attributes` is an array of objects that give the attributes bound to particular locations starting at 0.  Each of these attributes is either an array-like object of length 4 or less representing a constant attribute value, or else it is an object with the following properties that correspond to the parameters passed to [`gl.vertexAttribPointer`](http://www.khronos.org/opengles/sdk/docs/man/xhtml/glVertexAttribPointer.xml)\n\n    + `buffer` a [`gl-buffer`](https://github.com/mikolalysenko/gl-buffer) object encoding a webgl buffer\n    + `size` the size of the attribute (default 4)\n    + `type` the type of the attribute (default `gl.FLOAT`)\n    + `normalized` a flag that checks whether the attribute should be normalized or not\n    + `stride` the stride of the attribute **in bytes** (default 0)\n    + `offset` offset to the start of the attribute in the buffer **in bytes** (default 0)\n\n* `elements` is a buffer created using [`gl-buffer`](https://github.com/mikolalysenko/gl-buffer) encoding the state of the vertex elements\n\n* `elementsType` the type of data contained within the element buffer, if given. Defaults to `gl.UNSIGNED_SHORT`. Acceptable values are `gl.UNSIGNED_BYTE`, `gl.UNSIGNED_SHORT`. If the `OES_element_index_uint` extension is available and active, `gl.UNSIGNED_INT` may also be used.\n\n### `vao.bind()`\nBinds the vertex array object to the active vertex state.\n\n### `vao.unbind()`\nUnbinds the vertex array object.\n\n**Note** You should call this method before switching back to using vertex arrays and buffers as usual.  Failing to do so can cause the state of the vertex array object to become corrupted.  However, it is acceptable to skip the unbind step if another vertex array object is immediately bound.\n\n### `vao.draw(mode, count[, offset])`\nDraws the vertex array object.\n\n* `mode` is the mode to use when drawing the buffer, for example `gl.TRIANGLES`, `gl.LINES`, etc.\n* `count` is the number of vertices to draw.\n* `offset` is the offset to start drawing from.  Default `0`\n\n### `vao.update(attributes[, elements][, elementsType])`\nUpdates the contents of the vertex array object using the same syntax and conventions as the constructor.\n\n### `vao.dispose()`\nDestroys the vertex array object and releases all of its resources.\n\n\n## Credits\n(c) 2013 Mikola Lysenko. MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fgl-vao","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackgl%2Fgl-vao","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fgl-vao/lists"}