{"_id":"@ahmerhh/webgraphiclibrary-buffer","name":"@ahmerhh/webgraphiclibrary-buffer","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@ahmerhh/webgraphiclibrary-buffer","version":"1.0.0","description":"WebGL buffer wrapper.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/ahmerhh/WebGraphicLibrary-buffer.git"},"author":"","license":"ISC","bugs":{"url":"https://github.com/ahmerhh/WebGraphicLibrary-buffer/issues"},"homepage":"https://github.com/ahmerhh/WebGraphicLibrary-buffer#readme","_id":"@ahmerhh/webgraphiclibrary-buffer@1.0.0","gitHead":"1e5ec457867fc5b25961a48d90edfc26dc449c92","_nodeVersion":"18.15.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-CJ7pzfhNqIXUy+72OSkQHSJXXDVbM/pZV939Cb5aowHEmJ5kUUd78nFLbSfCUPhkuy8NXrr9tejvwJRtsrfIyA==","shasum":"06a3bd22cee972f9d8306f869baee06a058c9b15","tarball":"https://registry.npmjs.org/@ahmerhh/webgraphiclibrary-buffer/-/webgraphiclibrary-buffer-1.0.0.tgz","fileCount":4,"unpackedSize":4964,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDYgrnutnqMHH18M2MwUw2Ne+6JiNVW610nqGU1DlNPYAiEAkccVSJhAzTiERqZKaSNpnoOt6xOyuC9BK0TzuJpdVms="}]},"_npmUser":{"name":"ahmerhh","email":"ahmerhabibb@gmail.com"},"directories":{},"maintainers":[{"name":"ahmerhh","email":"ahmerhabibb@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webgraphiclibrary-buffer_1.0.0_1691926463000_0.8694730358098726"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-13T11:34:22.891Z","1.0.0":"2023-08-13T11:34:23.190Z","modified":"2023-08-13T11:34:23.412Z"},"maintainers":[{"name":"ahmerhh","email":"ahmerhabibb@gmail.com"}],"description":"WebGL buffer wrapper.","homepage":"https://github.com/ahmerhh/WebGraphicLibrary-buffer#readme","repository":{"type":"git","url":"git+https://github.com/ahmerhh/WebGraphicLibrary-buffer.git"},"bugs":{"url":"https://github.com/ahmerhh/WebGraphicLibrary-buffer/issues"},"license":"ISC","readme":"# @ahmerhh/WebGraphicLibrary-buffer\r\n\r\nWebGL buffer wrapper.\r\n\r\n## Installation\r\n\r\n``` sh\r\n$ npm install --save @ahmerhh/WebGraphicLibrary-buffer\r\n```\r\n\r\n## Usage\r\n\r\n``` js\r\nimport Buffer from '@ahmerhh/WebGraphicLibrary-buffer';\r\n\r\n// setup canvas, gl, program, etc.\r\n\r\nconst vertices = new Float32Array([\r\n  -1.0, -1.0,  0.0,\r\n   1.0, -1.0,  0.0,\r\n   1.0,  1.0,  0.0,\r\n  -1.0,  1.0,  0.0\r\n]);\r\n\r\nconst faces = new Uint16Array([\r\n  0, 1, 2,\r\n  0, 2, 3\r\n]);\r\n\r\nconst verticesBuffer = new Buffer(gl, gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);\r\nconst facesBuffer = new Buffer(gl, gl.ELEMENT_ARRAY_BUFFER, faces, gl.STATIC_DRAW);\r\n\r\nprogram.bind();\r\nverticesBuffer.bind();\r\nprogram.setAttributePointer('aPos');\r\nfacesBuffer.bind();\r\n\r\n// draw elements\r\n\r\n```\r\n\r\n## API\r\n\r\n#### `buffer = new Buffer(gl, type, data, usage)`\r\n\r\nCreate a new buffer, where:\r\n- `gl` is the [WebGraphicLibrary context](https://github.com/ahmerhh/WebGraphicLibrary-context).\r\n- `type` is the buffer type. Default is `gl.ARRAY_BUFFER`.\r\n- `data` is a typed array representing the data.\r\n- `usage` is the buffer usage type. Default is `gl.STATIC_DRAW`.\r\n\r\n#### `buffer.bind()`\r\n\r\nMake the buffer the active one.\r\n\r\n#### `buffer.dispose()`\r\n\r\nDelete instance. Calls `gl.deleteBuffer()`.\r\n\r\n## License\r\n\r\nMIT, see [LICENSE.md](https://github.com/ahmerhh/WebGraphicLibrary-buffer/blob/master/LICENSE.md) for more details.\r\n\r\n## Credits\r\n\r\nThanks to the amazing [stackgl](http://stack.gl/) for the inspiration.","readmeFilename":"README.md"}