[Mesa-dev] Mesa as part of OpenGL-on-OpenGL ES 2.0 (/WebGL)?

Alon Zakai alonzakai at gmail.com
Sat Mar 3 13:21:08 PST 2012


Hi everyone,

In the project I work on (Emscripten, an open source C/C++ to
JavaScript compiler that utilizes LLVM), we want to be able to
compile OpenGL games from desktop so that they work on
WebGL on the web. The main remaining difficulty for us is
to emulate the full OpenGL API using the WebGL API. WebGL
is close to OpenGL ES 2.0, so it has shaders but lacks the
fixed-function pipeline, glBegin etc.

So far we have some of the OpenGL ES 2.0 API implemented,
you can see a demo of it on the web here:

http://people.mozilla.org/~eakhgari/es2gears.html

We are looking for the best way to implement the OpenGL
API using the WebGL API, which is basically the problem of
implementing OpenGL on top of OpenGL ES 2.0. Note that
there is no problem with the fact that WebGL is a JavaScript
API, it would be enough to implement OpenGL on OpenGL
ES 2.0 in normal C/C++ code; we can automatically compile
that code into JavaScript.

There are several commercial products doing things of that
nature, one of the approaches seems to involve implementing
a "virtual OpenGL driver", basically a driver that implements
the OpenGL API and internally uses OpenGL ES 2.0 to actually
render.

Since Mesa implements OpenGL drivers, I was wondering if
there is some way for us to build on the Mesa code in order
to do that? Basically, if we had an implementation of the
full OpenGL API in C or C++, that we could in a reasonable
way get to utilize OpenGL ES 2.0 as its "backend", that would
be what we are looking for. Advice on the feasibility of that
with Mesa would be very welcome!

Alternatively, another approach we are considering is to
write such an implementation from scratch (of the fixed-
function pipeline etc.) in JavaScript + shaders. However
that sounds like more work than reusing existing code,
and also we would prefer to write code that can be
useful for other projects too (a C/C++ way to run OpenGL
on OpenGL ES 2.0 might be useful for other things than
our own project). So doing something more integrated
with Mesa, if that is feasible, sounds like it could be
preferable.

Best,
  Alon Zakai


More information about the mesa-dev mailing list