You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`gl` lets you create a WebGL context in [node.js](https://nodejs.org/en/) without making a window or loading a full browser environment.
7
+
`gl` lets you create a WebGL context in [Node.js](https://nodejs.org/en/) without making a window or loading a full browser environment.
8
8
9
9
It aspires to fully conform to the [WebGL 1.0.3 specification](https://www.khronos.org/registry/webgl/specs/1.0.3/).
10
10
11
11
## Warning!
12
12
13
-
This module is not actively developed. It's maintained enough to be working on all recent Node versions, but is unlikely to get new features or substantial bug fixes. If you want to take over the maintenance, please let us know in your pull requests!
13
+
This module is not actively developed. It's maintained enough to be working on [all current active and LTS Node.js releases,](https://nodejs.org/en/about/releases/) but is unlikely to get new features or substantial bug fixes. If you want to take over or assist with maintenance, please let us know in a pull request!
14
14
15
15
## Example
16
16
17
17
```javascript
18
-
//Create context
18
+
//Create context
19
19
var width =64
20
20
var height =64
21
21
var gl =require('gl')(width, height, { preserveDrawingBuffer:true })
Installing `headless-gl` on a supported platform is a snap using one of the prebuilt binaries. Using [npm](https://www.npmjs.com/) run the command,
40
+
Installing `headless-gl` on a supported platform is a snap using one of the prebuilt binaries. Using [npm](https://www.npmjs.com/) run the command,
40
41
41
42
```
42
43
npm install gl
43
44
```
44
45
45
46
And you are good to go! If your system is not supported, then please see the [development](#system-dependencies) section on how to configure your build environment. Patches to improve support are always welcome!
46
47
48
+
## Supported platforms and Node.js versions
49
+
50
+
gl runs on Linux, macOS, and Windows.
51
+
52
+
Node.js versions 8 and up are supported. **Note: due to an inadvertant low-level breaking change in libuv's process handling code, this package doesn't return a gl context when running nodejs version 12.13.1 and higher on macOS. A fix will be released in a future version of Node.js. Other platforms are unaffected.**
53
+
54
+
To support Node.js versions less than 8, use version 4.2.2 of this package.
55
+
47
56
## API
48
57
49
58
`headless-gl` exports exactly one function which you can use to create a WebGL context,
Creates a new `WebGLRenderingContext` with the given context attributes.
53
62
54
63
*`width` is the width of the drawing buffer
55
64
*`height` is the height of the drawing buffer
56
-
*`options` is an optional object whose properties are the context attributes for the WebGLRendering context
65
+
*`contextAttributes` is an optional object whose properties are the [context attributes for the WebGLRendering context](https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2)
* d3dcompiler_47.dll should be in c:\windows\system32, but if isn't then you can find another copy in the deps/ folder
150
-
* (optional) A modern nodejs supporting es6 to run some examples https://iojs.org/en/es6.html
151
159
152
160
## FAQ
153
161
@@ -173,7 +181,7 @@ addons:
173
181
- libglapi-mesa
174
182
- libosmesa6
175
183
node_js:
176
-
- '6'
184
+
- '8'
177
185
before_script:
178
186
- export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start
179
187
```
@@ -187,7 +195,7 @@ If you are running your own minimal Linux server, such as the one one would want
187
195
1.[Xvfb](https://en.wikipedia.org/wiki/Xvfb) is a lightweight X11 server which provides a back buffer for displaying X11 application offscreen and reading back the pixels which were drawn offscreen. It is typically used in Continuous Integration systems. It can be installed on CentOS with `yum install -y Xvfb`, and comes preinstalled on Ubuntu.
188
196
2.[Mesa](http://www.mesa3d.org/intro.html) is the reference open source software implementation of OpenGL. It can be installed on CentOS with `yum install -y mesa-dri-drivers`, or `apt-get install libgl1-mesa-dev`. Since a cloud Linux instance will typically run on a machine that does not have a GPU, a software implementation of OpenGL will be required.
189
197
190
-
Interacting with `Xvfb` requires you to start it on the background and to execute your `node` program with the DISPLAY environment variable set to whatever was configured when running Xvfb (the default being :99). If you want to do that reliably you'll have to start Xvfb from an init.d script at boot time, which is extra configuration burden. Fortunately there is a wrapper script shipped with Xvfb known as `xvfb-run` which can start Xvfb on the fly, execute your node program and finally shut Xvfb down. Here's how to run it:
198
+
Interacting with `Xvfb` requires you to start it on the background and to execute your `node` program with the DISPLAY environment variable set to whatever was configured when running Xvfb (the default being :99). If you want to do that reliably you'll have to start Xvfb from an init.d script at boot time, which is extra configuration burden. Fortunately there is a wrapper script shipped with Xvfb known as `xvfb-run` which can start Xvfb on the fly, execute your Node.js program and finally shut Xvfb down. Here's how to run it:
@@ -197,7 +205,7 @@ Yes, with [browserify](http://browserify.org/). The `STACKGL_destroy_context` a
197
205
198
206
### How are `<image>` and `<video>` elements implemented?
199
207
200
-
They aren't for now. If you want to upload data to a texture, you will need to unpack the pixels into a `Uint8Array` and feed it into `texImage2D`. To help reading and saving images, you should check out the following modules:
208
+
They aren't for now. If you want to upload data to a texture, you will need to unpack the pixels into a `Uint8Array` and feed it into `texImage2D`. To help reading and saving images, you should check out the following modules:
@@ -240,7 +248,7 @@ After you have your [system dependencies installed](#system-dependencies), do th
240
248
241
249
Once this is done, you should be good to go! A few more things
242
250
243
-
* To run the test cases, use the command `npm test`, or execute specific by just running it using node.
251
+
* To run the test cases, use the command `npm test`, or execute specific tests by just running them using `node`.
244
252
* On a Unix-like platform, you can do incremental rebuilds by going into the `build/` directory and running `make`. This is **way faster** running `npm build` each time you make a change.
0 commit comments