{"id":21668428,"url":"https://github.com/node-3d/glfw-raub","last_synced_at":"2025-04-05T08:09:53.281Z","repository":{"id":42351413,"uuid":"79730638","full_name":"node-3d/glfw-raub","owner":"node-3d","description":"GLFW for Node.js","archived":false,"fork":false,"pushed_at":"2025-02-26T09:06:39.000Z","size":21622,"stargazers_count":59,"open_issues_count":0,"forks_count":13,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T07:08:39.083Z","etag":null,"topics":["addon","bindings","cpp","gl","glfw","graphics","javascript","native","node-3d","opengl","window"],"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-22T16:50:38.000Z","updated_at":"2025-02-26T09:01:06.000Z","dependencies_parsed_at":"2023-02-07T02:16:55.859Z","dependency_job_id":"cc2d3e05-fdfe-48be-8605-992cfdc04f44","html_url":"https://github.com/node-3d/glfw-raub","commit_stats":{"total_commits":438,"total_committers":24,"mean_commits":18.25,"dds":0.5684931506849316,"last_synced_commit":"52a82220fbcbeb8ed0882b4bd361420275544cd5"},"previous_names":["raub/node-glfw"],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fglfw-raub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fglfw-raub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fglfw-raub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fglfw-raub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-3d","download_url":"https://codeload.github.com/node-3d/glfw-raub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305935,"owners_count":20917208,"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","glfw","graphics","javascript","native","node-3d","opengl","window"],"created_at":"2024-11-25T12:15:50.315Z","updated_at":"2025-04-05T08:09:53.262Z","avatar_url":"https://github.com/node-3d.png","language":"C++","readme":"# GLFW for Node.js\n\nThis is a part of [Node3D](https://github.com/node-3d) project.\n\n[![NPM](https://badge.fury.io/js/glfw-raub.svg)](https://badge.fury.io/js/glfw-raub)\n[![ESLint](https://github.com/node-3d/glfw-raub/actions/workflows/eslint.yml/badge.svg)](https://github.com/node-3d/glfw-raub/actions/workflows/eslint.yml)\n[![Test](https://github.com/node-3d/glfw-raub/actions/workflows/test.yml/badge.svg)](https://github.com/node-3d/glfw-raub/actions/workflows/test.yml)\n[![Cpplint](https://github.com/node-3d/glfw-raub/actions/workflows/cpplint.yml/badge.svg)](https://github.com/node-3d/glfw-raub/actions/workflows/cpplint.yml)\n\n```console\nnpm i -s glfw-raub\n```\n\n**Node.js** addon with **GLFW3** bindings.\n\n![Example](examples/screenshot.jpg)\n\n* **GLFW** version **3.4.0** backend.\n* Exposes low-level **GLFW** interface.\n* Multiple windows for a single **Node.js** process.\n* Able to switch to fullscreen and back.\n* Has `Window` class, simplifying low-level interactions.\n* Has `Document` class, capable of tricking other libs, as if we are in a browser.\n\n```js\nimport glfw from 'glfw-raub';\nconst { Window } = glfw;\n\nconst wnd = new Window({ title: 'GLFW Test', vsync: true });\n\nwnd.loop(() =\u003e {\n\tif (wnd.shouldClose || wnd.getKey(glfw.KEY_ESCAPE)) {\n\t\tprocess.exit(0);\n\t\treturn;\n\t}\n\t\n\tglfw.testScene(wnd.width, wnd.height);\n});\n```\n\n\u003e Note: this **addon uses N-API**, and therefore is ABI-compatible across different\nNode.js versions. Addon binaries are precompiled and **there is no compilation**\nstep during the `npm i` command.\n\n\n## GLFW\n\nThis is a low-level interface, where most of the stuff is directly reflecting\nGLFW API. GLFW **does NOT EXPOSE** OpenGL commands, it only [controls the window-related\nsetup and resources](http://www.glfw.org/docs/latest/group__window.html).\nTo access OpenGL/WebGL API you can use [webgl-raub](https://github.com/node-3d/webgl-raub)\nor any other similar addon.\n\nAside from several additional features, this addon directly exposes the GLFW API to JS. E.g.:\n\n```cpp\nDBG_EXPORT JS_METHOD(pollEvents) {\n\tglfwPollEvents();\n\tRET_GLFW_VOID;\n}\n```\n\nNothing is added between you and GLFW, unless necessary or explicitly mentioned.\n\n* All `glfw*` functions are accessible as\n    `glfw.*`. E.g. `glfwPollEvents` -\u003e `glfw.pollEvents`.\n* All `GLFW_*` constants are accessible as\n    `glfw.*`. E.g. `GLFW_TRUE` -\u003e `glfw.TRUE`.\n* Method `glfw.createWindow` takes some additional arguments. This is mostly related to\n    JS events being generated from GLFW callbacks,\n    and here's where you provide an Emitter object.\n* Pointers are directly exposed as numbers to JS and are expected as\n    arguments in specific methods. Such as, `glfw.createWindow` returns a number\n    (pointer), and then you provide it back to e.g. `glfw.setWindowTitle`.\n\nSee [this example](/examples/vulkan.mjs) for raw GLFW calls.\n\nSee [TS declarations](/index.d.ts) for more details.\n\n----------\n\n\n### class Window\n\n```js\nconst { Window } = glfw;\nconst wnd = new Window({ title: 'GLFW Test', vsync: true });\n```\n\nThis class helps managing window objects and their events. It can also switch between\nfullscreen, borderless and windowed modes.\n\nThe first window creates an additional invisible root-window for context sharing\n(so that you can also close any window and still keep the root context).\nThe platform context (pointers/handles) for sharing may be obtained when necessary.\n\nSee [TS declarations](/index.d.ts) for more details.\n\n----------\n\n### class Document\n\n```js\nconst { Document } = glfw;\nconst doc = new Document({ title: 'GLFW Test', vsync: true });\n```\n\nDocument inherits from `Window` and has the same features in general.\nIt exposes additional APIs to mimic the content of web `document`.\nThere are some tricks to provide WebGL libraries with necessary environment.\nDocument is specifically designed for compatibility with [three.js](https://threejs.org/).\nOther web libraries may work too, but may require additional tweaking.\n\nSee [TS declarations](/index.d.ts) for more details.\n\n----------\n\n### Extras\n\n* `glfw.hideConsole(): void` - tries to hide the console window on Windows.\n* `glfw.showConsole(): void` - shows the console window if it has been hidden.\n* `glfw.drawWindow(w: number, cb: (dateNow: number) =\u003e void): void` - this is a shortcut\n    to call `pollEvents`, then `cb`, and then `swapBuffers`, where you only supply `cb`\n    and C++ side does the rest.\n* `glfw.platformDevice(w: number): number` - returns the window HDC on Windows,\n    or whatever is similar on other systems.\n* `glfw.platformWindow(w: number): number` - returns the window HWND on Windows,\n    or whatever is similar on other systems.\n* `glfw.platformContext(w: number): number` - returns the window WGL Context on Windows,\n    or whatever is similar on other systems.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-3d%2Fglfw-raub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-3d%2Fglfw-raub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-3d%2Fglfw-raub/lists"}