@@ -46,42 +46,77 @@ step during the `npm i` command.
4646## GLFW
4747
4848This is a low-level interface, where most of the stuff is directly reflecting
49- GLFW API. It ** does NOT EXPOSE** OpenGL commands.
50- See [ GLFW Docs] ( http://www.glfw.org/docs/latest/group__window.html )
51- for useful info on what it does and doesn't.
52-
53- ``` js
54- const glfw = require (' glfw-raub' );
49+ GLFW API. GLFW ** does NOT EXPOSE** OpenGL commands, it only [ controls the window-related
50+ setup and resources] ( http://www.glfw.org/docs/latest/group__window.html ) .
51+ Aside from several additional features, this addon directly exposes the GLFW API to JS. E.g.:
52+
53+ ``` cpp
54+ DBG_EXPORT JS_METHOD (pollEvents) {
55+ glfwPollEvents();
56+ RET_GLFW_VOID;
57+ }
5558```
5659
57- Here ` glfw ` is an API container, where all ` glfw* ` functions are accessible as
58- ` glfw.* ` . E.g. ` glfwSetWindowTitle ` -> ` glfw.setWindowTitle ` .
60+ Nothing is added between you and GLFW, unless necessary or explicitly mentioned.
61+
62+ * All `glfw*` functions are accessible as
63+ `glfw.*`. E.g. `glfwPollEvents` -> `glfw.pollEvents`.
64+ * All `GLFW_*` constants are accessible as
65+ `glfw.*`. E.g. `GLFW_TRUE` -> `glfw.TRUE`.
5966
60- See [ TypeScript definitions] ( /index.d.ts ) for more details.
67+
68+ See [this example](/examples/vulkan.mjs) for raw GLFW calls.
69+
70+ See [TS declarations](/index.d.ts) for more details.
6171
6272----------
6373
6474
6575### class Window
6676
6777```js
68- const { Window } = require (' glfw-raub' );
78+ const { Window } = glfw;
79+ const wnd = new Window({ title: 'GLFW Test', vsync: true });
6980```
7081
7182This class helps managing window objects and their events. It can also switch between
7283fullscreen, borderless and windowed modes.
7384
74- See [ TypeScript definitions] ( /index.d.ts ) for more details.
85+ The first window creates an additional invisible root-window for context sharing.
86+ (so that you can also close any window and still keep the root context).
87+ The platform context (pointers/handles) for sharing may be obtained when necessary.
88+
89+ See [ TS declarations] ( /index.d.ts ) for more details.
7590
7691----------
7792
7893### class Document
7994
8095``` js
81- const { Document } = require (' glfw-raub' );
96+ const { Document } = glfw;
97+ const doc = new Document ({ title: ' GLFW Test' , vsync: true });
8298```
8399
84- It can be used to facilitate the environment for other
85- JS libraries, such as [ three.js] ( https://threejs.org/ ) .
100+ Document inherits from ` Window ` and has the same features in general.
101+ It exposes additional APIs to mimic the content of web ` document ` .
102+ There are some tricks to provide WebGL libraries with necessary environment.
103+ Document is specifically designed for compatibility with [ three.js] ( https://threejs.org/ ) .
104+ Other web libraries may work too, but may require additional tweaking.
105+
106+ See [ TS declarations] ( /index.d.ts ) for more details.
107+
108+ ----------
86109
87- See [ TypeScript definitions] ( /index.d.ts ) for more details.
110+ ### Extras
111+
112+ * ` glfw.hideConsole(): void ` - tries to hide the console window on Windows.
113+ * ` glfw.showConsole(): void ` - shows the console window if it has been hidden.
114+ * ` glfw.drawWindow(w: number, cb: (dateNow: number) => void): void ` - this is a shortcut
115+ to call ` pollEvents ` , then ` cb ` , and then ` swapBuffers ` , where you only supply ` cb `
116+ and C++ side does the rest.
117+ * ` glfw.platformDevice(w: number): number ` - returns the window HDC on Windows,
118+ or whatever is similar on other systems.
119+ * ` glfw.platformWindow(w: number): number ` - returns the window HWND on Windows,
120+ or whatever is similar on other systems.
121+ * ` glfw.platformContext(w: number): number ` - returns the window WGL Context on Windows,
122+ or whatever is similar on other systems.
0 commit comments