Skip to content

Commit cfacb91

Browse files
committed
Update readme
1 parent fb1c7a3 commit cfacb91

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

README.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This is a part of [Node3D](https://github.com/node-3d) project.
1111
npm i -s webgl-raub
1212
```
1313

14-
> This addon is ABI-compatible across Node.js versions. **There is no compilation** during the `npm install`.
14+
> This addon is ABI-compatible across Node.js versions. **There is no compilation** during `npm i`.
1515
1616
![Example](examples/screenshot.jpg)
1717

@@ -25,25 +25,13 @@ import webgl from 'webgl-raub';
2525
Here `webgl` contains the **WebGL/OpenGL** API, like a `WebGLRenderingContext` instance would.
2626
* See [WebGLRenderingContext docs](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
2727
for reference.
28-
* See [TS declarations](/index.d.ts) for the full list of exports.
2928
* There are also non-WebGL methods exported in case you want to use advanced OpenGL functions.
3029
* The addon **does not provide** a window control system, you can use
3130
[glfw-raub](https://github.com/node-3d/glfw-raub) (or anything else!) to create a window.
31+
* See [TS declarations](/index.d.ts) for the full list of exports.
3232

33-
The JS API mostly maps the native OpenGL function calls. E.g.:
3433

35-
```cpp
36-
// gl.clear(target)
37-
DBG_EXPORT JS_METHOD(clear) { NAPI_ENV;
38-
REQ_INT32_ARG(0, target);
39-
glClear(target);
40-
RET_WEBGL_VOID;
41-
}
42-
```
43-
44-
You can optionally call `webgl.init()` after the GL context becomes available - this translates
45-
into a `glewInit()` call. See [GLEW docs](https://glew.sourceforge.net/basic.html) for what
46-
it does and if you need it (probably "yes"?).
34+
## WebGL Libs
4735

4836
To use browser **WebGL** libs, like [three.js](https://threejs.org/),
4937
several additional interfaces must also be provided to mimic the browser.
@@ -73,15 +61,36 @@ Similarly, these modules are utilized in [3d-core-raub](https://github.com/node-
7361
Using [3d-core-raub](https://github.com/node-3d/3d-core-raub), you can skip setting up
7462
most environment features for those libs.
7563

76-
77-
## WebGL Libs
78-
7964
* [three.js](https://threejs.org/) - known to work well on **Node.js** with this
8065
implementation of **WebGL**.
8166
* [PixiJS](https://pixijs.com/) - seems to work with some minor hacks, as proven by this
8267
[example](https://github.com/node-3d/3d-core-raub/blob/master/examples/pixi/index.js).
8368

8469

70+
## Native OpenGL
71+
72+
This is real **native OpenGL**, not ANGLE or anything else.
73+
You have direct access to GL resource IDs. Due to WebGL
74+
convention, resource IDs are wrapped in objects, such as `WebGLBuffer`. All of them
75+
contain raw IDs as `obj._` - the `_` property. You can also create such objects based on
76+
OpenGL IDs that are obtained elsewhere (e.g. from other separate C++ addons).
77+
78+
The JS API mostly maps the native OpenGL function calls. E.g.:
79+
80+
```cpp
81+
// gl.clear(target)
82+
DBG_EXPORT JS_METHOD(clear) { NAPI_ENV;
83+
REQ_INT32_ARG(0, target);
84+
glClear(target);
85+
RET_WEBGL_VOID;
86+
}
87+
```
88+
89+
You can optionally call `webgl.init()` after the GL context becomes available - this translates
90+
into a `glewInit()` call. See [GLEW docs](https://glew.sourceforge.net/basic.html) for what
91+
it does and if you need it (probably "yes"?).
92+
93+
8594
## MacOS Note
8695
8796
Some features may depend on OpenGL profile being used. Core profile

0 commit comments

Comments
 (0)