Skip to content
Werner Beroux edited this page May 13, 2019 · 4 revisions

Quick tutorial on using Regal with Emscripten

Foreword: This is based on the very limited experience of myself as a user of this library. I'm not claiming anything below to be expert knowledge.

Why

Regal adds support for older OpenGL functions that aren't natively supported by Emscripten even with -s LEGACY_GL_EMULATION=1.

How to use this library

I'm assuming here that you're running a Linux shell with basic libraries.

Compile Regal

For Ubuntu the dependencies (including Emscripten dependencies) may be like:

$ apt update && apt install -y \
    build-essential \
    curl \
    libglu1-mesa-dev \
    libsdl1.2-dev \
    libxi-dev \
    libxmu-dev \
    python \
    nodejs \
    cmake \
    default-jre

Then compile:

$ mkdir /opt/regal
$ curl -L https://github.com/emscripten-ports/regal/tarball/master | tar xz --strip-components=1 -C /opt/regal
$ cd /opt/regal
$ make -f Makefile.regal

Use it in your project to fix OpenGL compilation issues

Edit your source code like:

#ifdef __EMSCRIPTEN__
#include <GL/Regal.h>     # Add this before OpenGL includes.
#include <GL/RegalGLU.h>  # Optional.
#include <emscripten.h>   # This you should already have.
#endif

#include <GL/glu.h>  # Your existing OpenGL include should come after Regal.

Then after activating Emscripten, compile:

$ em++ src/*.cpp -lSDL -I/opt/regal/include -L/opt/regal/lib/linux -lRegal -lRegalGLU -s USE_REGAL=1

Note here:

Clone this wiki locally