Skip to content
WPE WebGL Node.js module
Branch: master
Clone or download
basvanmeurs Merge pull request #10 from goruklu/master
gles2nexusimpl has wrong prototype for init()
Latest commit 3df8fdb Mar 2, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples - try out rpi/nexus gyp bindings Mar 20, 2017
lib allow null for image data in texImage2d Aug 3, 2017
src fixed the init() function prototype for Nexus implementation. Mar 2, 2019
.gitignore initial commit with examples Mar 9, 2017
LICENSE Update LICENSE Mar 9, 2017 allow setting the display number for RPi, so that we can overlay a UI… Dec 28, 2017
binding.gyp fix for raspbian Dec 28, 2017
gles2.js allow setting the display number for RPi, so that we can overlay a UI… Dec 28, 2017


npm version npm Donate

Provides a WebGL rendering context for nodejs. It is displayed in a window or fullscreen, depending on your platform.


Because on some targets OpenGL must be used instead of OpenGL ES2, you must do the following in your shaders:

#ifdef GL_ES
precision highp float;


Linux, OSX, Windows (GLEW/GLFW platforms)

GLFW and GLEW provides us with the functionality to start a OpenGL-enabled window. There are minor differences between OpenGL ES2 (WebGL) and OpenGL using GLEW. For more information, see:

Raspberry PI

This module requires node 4+. Please install from nodesource

curl -sL | sudo -E bash -

Use Raspbian or make sure that includes and libs are in /opt/vc. Raspbian has a default GPU memory setting of 64M, which is quite low. It may lead to 0x0505 (out of memory) errors. You can increase this to a higher number using raspi-config.


Linux: libglew-dev libglfw3-dev

Mac OSX: Use Homebrew brew install pkg-config glfw3 glew For help with issues when installing pkg-config, see

Windows: glew32.lib opengl32.lib


var webgl = require('wpe-webgl');

var options = {width: 1280, height: 720};
var gl = webgl.init(options);

while(true) {
    gl.clearColor(0, 1.0, 1.0, 0.0);

    // Set the viewport
    gl.viewport( 0, 0, 1280, 720);

    // Clear the color buffer

    // Do other GL-related stuff here.

    webgl.nextFrame(true /* Use false to prevent buffer swapping */);

A couple of more elaborate examples can be found in the examples folder.


Name Description
width viewport width in px
height viewport height in px
fullscreen window or fullscreen?
title window title
layer display layer (RPI only)
You can’t perform that action at this time.