Skip to content

Commit f43fd6a

Browse files
committed
Adjust readme
1 parent 173f9a6 commit f43fd6a

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ step during the `npm i` command.
4848
This is a low-level interface, where most of the stuff is directly reflecting
4949
GLFW API. GLFW **does NOT EXPOSE** OpenGL commands, it only [controls the window-related
5050
setup and resources](http://www.glfw.org/docs/latest/group__window.html).
51+
To access OpenGL/WebGL API you can use [webgl-raub](https://github.com/node-3d/webgl-raub)
52+
or any other similar addon.
53+
5154
Aside from several additional features, this addon directly exposes the GLFW API to JS. E.g.:
5255

5356
```cpp
@@ -63,7 +66,12 @@ Nothing is added between you and GLFW, unless necessary or explicitly mentioned.
6366
`glfw.*`. E.g. `glfwPollEvents` -> `glfw.pollEvents`.
6467
* All `GLFW_*` constants are accessible as
6568
`glfw.*`. E.g. `GLFW_TRUE` -> `glfw.TRUE`.
66-
69+
* Method `glfw.createWindow` takes some additional arguments. This is mostly related to
70+
JS events being generated from GLFW callbacks,
71+
and here's where you provide an Emitter object.
72+
* Pointers are directly exposed as numbers to JS and are expected as
73+
arguments in specific methods. Such as, `glfw.createWindow` returns a number
74+
(pointer), and then you provide it back to e.g. `glfw.setWindowTitle`.
6775
6876
See [this example](/examples/vulkan.mjs) for raw GLFW calls.
6977
@@ -82,7 +90,7 @@ const wnd = new Window({ title: 'GLFW Test', vsync: true });
8290
This class helps managing window objects and their events. It can also switch between
8391
fullscreen, borderless and windowed modes.
8492

85-
The first window creates an additional invisible root-window for context sharing.
93+
The first window creates an additional invisible root-window for context sharing
8694
(so that you can also close any window and still keep the root context).
8795
The platform context (pointers/handles) for sharing may be obtained when necessary.
8896

src/cpp/glfw-context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ DBG_EXPORT JS_METHOD(makeContextCurrent) { THIS_WINDOW;
1212

1313
DBG_EXPORT JS_METHOD(getCurrentContext) { NAPI_ENV;
1414
GLFWwindow *window = glfwGetCurrentContext();
15-
RET_NUM(reinterpret_cast<uint64_t>(window));
15+
RET_PTR(window);
1616
}
1717

1818
} // namespace glfw

src/cpp/glfw-cursor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ DBG_EXPORT JS_METHOD(createCursor) { NAPI_ENV;
6363
cursor = glfwCreateCursor(&image, image.width / 2, image.height / 2);
6464
}
6565

66-
RET_NUM(reinterpret_cast<uint64_t>(cursor));
66+
RET_PTR(cursor);
6767
}
6868

6969
DBG_EXPORT JS_METHOD(createStandardCursor) { NAPI_ENV;
7070
REQ_INT32_ARG(0, shape);
7171
GLFWcursor *cursor = glfwCreateStandardCursor(shape);
72-
RET_NUM(reinterpret_cast<uint64_t>(cursor));
72+
RET_PTR(cursor);
7373
}
7474

7575

src/cpp/glfw-vulkan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ DBG_EXPORT JS_METHOD(createWindowSurface) { NAPI_ENV; THIS_VULKAN;
7878
RET_NULL;
7979
}
8080

81-
RET_NUM(reinterpret_cast<uint64_t>(surface));
81+
RET_PTR(surface);
8282
}
8383

8484

@@ -110,7 +110,7 @@ DBG_EXPORT JS_METHOD(vulkanCreateInstance) { NAPI_ENV;
110110
RET_NULL;
111111
}
112112

113-
RET_NUM(reinterpret_cast<uint64_t>(instance));
113+
RET_PTR(instance);
114114
}
115115

116116

src/cpp/glfw-window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ DBG_EXPORT JS_METHOD(createWindow) { NAPI_ENV;
190190
glfwSetCursorEnterCallback(window, cursorEnterCB);
191191
glfwSetScrollCallback(window, scrollCB);
192192

193-
RET_NUM(reinterpret_cast<uint64_t>(window));
193+
RET_PTR(window);
194194
}
195195

196196

0 commit comments

Comments
 (0)