{"id":20778049,"url":"https://github.com/stackgl/gl-buffer-snoop","last_synced_at":"2025-04-30T18:41:00.549Z","repository":{"id":22762961,"uuid":"26108675","full_name":"stackgl/gl-buffer-snoop","owner":"stackgl","description":"Intercepts uploads to WebGL buffers in order to keep track of their expected value on the GPU.","archived":false,"fork":false,"pushed_at":"2014-11-03T07:47:51.000Z","size":100,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-11T22:23:03.890Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","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.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-03T07:47:36.000Z","updated_at":"2022-02-26T17:30:36.000Z","dependencies_parsed_at":"2022-08-21T12:30:21.772Z","dependency_job_id":null,"html_url":"https://github.com/stackgl/gl-buffer-snoop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-buffer-snoop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-buffer-snoop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-buffer-snoop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fgl-buffer-snoop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackgl","download_url":"https://codeload.github.com/stackgl/gl-buffer-snoop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225040892,"owners_count":17411554,"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:51.403Z","updated_at":"2024-11-17T13:18:52.001Z","avatar_url":"https://github.com/stackgl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gl-buffer-snoop\n![](http://img.shields.io/badge/stability-experimental-orange.svg?style=flat)\n![](http://img.shields.io/npm/v/gl-buffer-snoop.svg?style=flat)\n![](http://img.shields.io/npm/dm/gl-buffer-snoop.svg?style=flat)\n![](http://img.shields.io/npm/l/gl-buffer-snoop.svg?style=flat)\n\nIntercepts uploads to WebGL buffers in order to keep track of their expected\nvalue on the GPU.\n\nDesigned solely with the intention of testing packages that interact with\nWebGL buffers. It's probably not something you should be using in an actual\napp/demo, so approach with caution.\n\n## Usage\n\n[![NPM](https://nodei.co/npm/gl-buffer-snoop.png)](https://nodei.co/npm/gl-buffer-snoop/)\n\n### `snoop(gl)`\n\nBefore using your WebGL context at all, you should let `gl-buffer-snoop` do\nits thing by passing it the context in question:\n\n``` javascript\nvar canvas = document.createElement('canvas')\nvar gl = canvas.getContext('webgl')\n\nrequire('gl-buffer-snoop')(gl)\n```\n\nThis will override a few of the context's methods to keep track of outgoing\ndata, along with providing a new method for you to use to retrieve a buffer's\ndata:\n\n### `gl.getBufferData(buffer)`\n\nGiven an instance of a `WebGLBuffer`, returns our local copy of the data it\nshould have stored on the GPU. This is returned as a `Uint8Array`, but you\ncan easily convert it to other types too thanks to the magic of typed arrays.\nFor example:\n\n``` javascript\nvar buffer = gl.createBuffer()\n// ...\nvar rawData = gl.getBufferData(buffer)\nvar floatData = new Float32Array(rawData.buffer)\n```\n\nIf you're using this with [gl-buffer](http://github.com/stackgl/gl-buffer),\nyou can just use the `handle` property to access the underlying buffer instance:\n\n``` javascript\nvar buffer = require('gl-buffer')(gl, [1, 2, 3])\nvar rawData = gl.getBufferData(buffer.handle)\nvar floatData = new Float32Array(rawData.buffer)\n\nconsole.log(floatData) // [1, 2, 3]\n```\n\n## License\n\nMIT. See [LICENSE.md](http://github.com/stackgl/gl-buffer-snoop/blob/master/LICENSE.md)\nfor details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fgl-buffer-snoop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackgl%2Fgl-buffer-snoop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fgl-buffer-snoop/lists"}