emscripten & BananaBread (3D tech... not the food)

Discussion about everything. New games, 3d math, development tips...
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

emscripten & BananaBread (3D tech... not the food)

Post by CuteAlien »

This looks pretty interesting, someone compiled a (test-)game using Sauerbraten (a c++ engine) into JavaScript using emscripten. I'm not 100% certain yet how that works exactly. Somehow the game is compiled into the llvm intermediate language (using clang, but maybe other llvm compiler not running on OsX can also do that). llvm bitcode is then compiled to Javascript. I get that part, but not really certain yet how the API-calls get translated by this (for example OpenGL ES->WebGL, or all the other system-api calls). But maybe emscripten can do all that.

https://developer.cdn.mozilla.net/media ... index.html

Guess it's time testing Irrlicht compiles on LLVM as well - anyone tried that already?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: BananaBread (3D tech... not the food)

Post by Mel »

I saw that demo, but with this (lame) computer i can't run it smooth exactly... Suposedly the WebGL interface is exposed to JavaScript and most of the web languages, so it really doesn't matter how you write your stuff.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: BananaBread (3D tech... not the food)

Post by CuteAlien »

Sure, the WebGL interface is mainly there for Javascript. The question that still puzzles me is how for example the OpenGL function calls get switched to WebGL calls... as the translation step seems to be on the level of the LLVM bitcode.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: BananaBread (3D tech... not the food)

Post by Mel »

Now that is something odd... maybe it works because the function calls have the same name? or some specific conversion for OpenGL to WebGL?
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
eye776
Posts: 94
Joined: Sun Dec 28, 2008 11:07 pm

Re: BananaBread (3D tech... not the food)

Post by eye776 »

From wikipedia "WebGL is based on OpenGL ES 2.0". Probably the same names.
Binary translaton isn't a new trick MIDLet Pascal, MoSync and cibyl compile c++, pascal and respectively c code to j2me bytecode. The latter two use an IL (kinda like MSIL) that gets recompiled to target platform bytecode.
What's new about this is that you basically get to play 3d games on standard tech available in the 2 most popular desktop browsers.

No I don't know how irrlicht's smart pointer arch would translate in such a scenario.
IIRC nobody will know unless someone does the same thing with a basic irrlicht demo (put it through emscripten).
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: BananaBread (3D tech... not the food)

Post by sudi »

Well the website states it works with the sauerbraten engine....last time i checked saubraten hides any direct opengl calls. So they just had to write a saubraten wrapper in javascript.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: BananaBread (3D tech... not the food)

Post by gerdb »

i tested the demos, my result:

half-life 2 runs 100 times faster, looks much better, is from 2004. What a waste of energy, its just melting our planet faster.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: BananaBread (3D tech... not the food)

Post by serengeor »

gerdb wrote:i tested the demos, my result:

half-life 2 runs 100 times faster, looks much better, is from 2004. What a waste of energy, its just melting our planet faster.
lol, found best two things to compare :roll:
Working on game: Marrbles (Currently stopped).
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: BananaBread (3D tech... not the food)

Post by CuteAlien »

It was a new technology and so development didn't stop. Today it was announced that Firefox (nightly build) comes now with an optimization module (called asm.js) that makes sure the kind of js code produced by emscripten will run much faster in Firefox: https://blog.mozilla.org/luke/2013/03/2 ... x-nightly/
So it's now possible to have code that's only around 50% slower than native c++ code running in a webbrowser. And even more important - this kind of code runs without gc causing undeterministic time behaviour - so it's way nicer for games than js was so far. I wouldn't be too surprised seeing other browser doing further optimizations to their js engines as well certainly.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: emscripten & BananaBread (3D tech... not the food)

Post by CuteAlien »

Next cool thing done with emscripten - the Unreal 3 Engine now runs on the web: https://blog.mozilla.org/blog/2013/03/2 ... or-gaming/

Did a quick check yesterday and seems Irrlicht trunk at least compiles with clang++ already. Unfortunately I only got clang 3.0 in my repositories and emscripten needs 3.2 (will try installing clang manually). Seems to get WebGL support we need to use OpenGL ES2.0 (https://github.com/kripken/emscripten/w ... GL-support). So I guess to get Irrlicht running in a browser we should start with the ogl-es branch.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: emscripten & BananaBread (3D tech... not the food)

Post by Mel »

The only thing that they still can't do is load content faster over the net... I don't think it is very practical to have a web load hundreds upon hundreds of megs just to show it can run the Unreal Engine 3, not that it isn't a great achievement, but that i see it very little practical.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: emscripten & BananaBread (3D tech... not the food)

Post by CuteAlien »

Yeah, that is pretty good point, for large games having more local storage than html offers so far would be better (or huge bandwidth costs and constantly downloads... I think Runescape for example is doing that).

Maybe this motivates people to use more procedural content...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: emscripten & BananaBread (3D tech... not the food)

Post by hybrid »

I think that not only Flash has a way to store things locally, so it should be possible to cache these things and reload from disk later on.
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: emscripten & BananaBread (3D tech... not the food)

Post by CuteAlien »

You can store around 5 MB per with html 5 local storage (browsers might allow more, but 5MB are pretty much guaranteed). 5 MB are unfortunately not much for games.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: emscripten & BananaBread (3D tech... not the food)

Post by serengeor »

I already saw a bunch of 3D games before that stored their contents locally, but that was at least 5 years ago.
Working on game: Marrbles (Currently stopped).
Post Reply