{"id":15054358,"url":"https://github.com/node-3d/webgl-raub","last_synced_at":"2025-04-04T13:07:08.058Z","repository":{"id":42350318,"uuid":"79739286","full_name":"node-3d/webgl-raub","owner":"node-3d","description":"OpenGL/WebGL for Node.js","archived":false,"fork":false,"pushed_at":"2025-03-01T10:23:26.000Z","size":8249,"stargazers_count":86,"open_issues_count":0,"forks_count":13,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T12:02:22.536Z","etag":null,"topics":["addon","bindings","cpp","gl","graphics","javascript","native","node-3d","opengl","webgl"],"latest_commit_sha":null,"homepage":"https://github.com/node-3d/node-3d","language":"C++","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/node-3d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-22T19:18:33.000Z","updated_at":"2025-03-06T08:34:26.000Z","dependencies_parsed_at":"2024-06-02T07:36:04.452Z","dependency_job_id":"c04eb31b-3fd1-4496-9cc1-413b41a74913","html_url":"https://github.com/node-3d/webgl-raub","commit_stats":{"total_commits":371,"total_committers":26,"mean_commits":14.26923076923077,"dds":0.6469002695417789,"last_synced_commit":"1d92e985a52b908bf5276228e9fe147c02669f95"},"previous_names":["raub/node-webgl"],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fwebgl-raub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fwebgl-raub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fwebgl-raub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fwebgl-raub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-3d","download_url":"https://codeload.github.com/node-3d/webgl-raub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174468,"owners_count":20896078,"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":["addon","bindings","cpp","gl","graphics","javascript","native","node-3d","opengl","webgl"],"created_at":"2024-09-24T21:38:42.355Z","updated_at":"2025-04-04T13:07:08.027Z","avatar_url":"https://github.com/node-3d.png","language":"C++","readme":"# WebGL for Node.js\n\nThis is a part of [Node3D](https://github.com/node-3d) project.\n\n[![NPM](https://badge.fury.io/js/webgl-raub.svg)](https://badge.fury.io/js/webgl-raub)\n[![ESLint](https://github.com/node-3d/webgl-raub/actions/workflows/eslint.yml/badge.svg)](https://github.com/node-3d/webgl-raub/actions/workflows/eslint.yml)\n[![Test](https://github.com/node-3d/webgl-raub/actions/workflows/test.yml/badge.svg)](https://github.com/node-3d/webgl-raub/actions/workflows/test.yml)\n[![Cpplint](https://github.com/node-3d/webgl-raub/actions/workflows/cpplint.yml/badge.svg)](https://github.com/node-3d/webgl-raub/actions/workflows/cpplint.yml)\n\n```console\nnpm i -s webgl-raub\n```\n\n\u003e This addon is ABI-compatible across Node.js versions. **There is no compilation** during `npm i`.\n\n![Example](examples/screenshot.jpg)\n\n**TL;DR**: For a quick start, use [3d-core-raub](https://github.com/node-3d/3d-core-raub)\nor look at [Examples](/examples).\n\n```js\nimport webgl from 'webgl-raub';\n```\n\nHere `webgl` contains the **WebGL/OpenGL** API, like a `WebGLRenderingContext` instance would.\n* See [WebGLRenderingContext docs](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)\n    for reference.\n* There are also non-WebGL methods exported in case you want to use advanced OpenGL functions.\n* The addon **does not provide** a window control system, you can use\n    [glfw-raub](https://github.com/node-3d/glfw-raub) (or anything else!) to create a window.\n* See [TS declarations](/index.d.ts) for the full list of exports.\n\n\n## WebGL Libs\n\nTo use browser **WebGL** libs, like [three.js](https://threejs.org/),\nseveral additional interfaces must also be provided to mimic the browser.\n\n* Package [glfw-raub](https://github.com/node-3d/glfw-raub) provides window/context handling\nand additional browser-like interfaces.\n* Package [image-raub](https://github.com/node-3d/glfw-raub) loads and serves the image data as web\n[Image](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement#example) would.\n\nSee [this example](/examples/textured.mjs) using both **GLFW** and **Image**.\nThe main idea being as follows:\n\n```js\nimport Image from 'image-raub';\nimport webgl from 'webgl-raub';\nimport glfw from 'glfw-raub';\nconst { Document } = glfw;\n\nDocument.setImage(image); // plug Image impl into the Document\nDocument.setWebgl(webgl); // plug WebGL impl into the Document\n\nconst doc = new Document({ width: 1600, height: 900, vsync: true });\n...\n```\n\nSimilarly, these modules are utilized in [3d-core-raub](https://github.com/node-3d/3d-core-raub).\nUsing [3d-core-raub](https://github.com/node-3d/3d-core-raub), you can skip setting up\nmost environment features for those libs.\n\n* [three.js](https://threejs.org/) - known to work well on **Node.js** with this\nimplementation of **WebGL**.\n* [PixiJS](https://pixijs.com/) - seems to work with some minor hacks, as proven by this\n[example](https://github.com/node-3d/3d-core-raub/blob/master/examples/pixi/index.js).\n\n\n## Native OpenGL\n\nThis is real **native OpenGL**, not ANGLE or anything else.\nYou have direct access to GL resource IDs. Due to WebGL\nconvention, resource IDs are wrapped in objects, such as `WebGLBuffer`. All of them\ncontain raw IDs as `obj._` - the `_` property. You can also create such objects based on\nOpenGL IDs that are obtained elsewhere (e.g. from other separate C++ addons).\n\nThe JS API mostly maps the native OpenGL function calls. E.g.:\n\n```cpp\n// gl.clear(target)\nDBG_EXPORT JS_METHOD(clear) { NAPI_ENV;\n\tREQ_INT32_ARG(0, target);\n\tglClear(target);\n\tRET_WEBGL_VOID;\n}\n```\n\nYou can optionally call `webgl.init()` after the GL context becomes available - this translates\ninto a `glewInit()` call. See [GLEW docs](https://glew.sourceforge.net/basic.html) for what\nit does and if you need it (probably \"yes\"?).\n\n\n## MacOS Note\n\nSome features may depend on OpenGL profile being used. Core profile\nis necessary for VAO and other OpenGL 3.2+ features. Depending on your windowing\nbackend, set the OpenGL profile of your preference.\nIn case [glfw-raub](https://github.com/node-3d/glfw-raub) is used,\nthe profile can be set through the `Window`/`Document`\n[constructor](https://github.com/node-3d/glfw-raub#class-window) or with\n`glfw.windowHint` calls.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-3d%2Fwebgl-raub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-3d%2Fwebgl-raub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-3d%2Fwebgl-raub/lists"}