BananaBread: Porting Cube 2 to the Web |
by kripken
on 05/04/2012 00:02, 143 messages, last message: 11/10/2016 01:26, 64918 views, last view: 12/09/2021 04:09 |
 |
|
Over the last month I've been working to get Sauerbraten running on the web, here is a demo of what I have so far:
http://syntensity.com/static/bb/client.html
Press the "fullscreen" button below the screen, then press "GO!".
That is the Sauerbraten C++ code, compiled to JavaScript and WebGL. It runs at 60fps on my laptop on both Firefox and Chrome, but note that it has not been optimized *at all* yet. I'm posting here because I just got what you see in the demo to work, not because it's finished ;) In particular, the code is not optimized or even minified, and when you press "GO!" it loads an ugly level that I made (I have no artistic talent). So ignore the performance, download time, and artwork. This is just a very very early demo.
Note that you need a very recent browser for the demo to work 100%. Firefox Nightly (15) has fullscreen and pointer lock, for example, but earlier versions don't, the same is true for Chrome. Stable versions of those browsers probably will not work so well, you'll need dev versions (nightly or beta for Firefox, canary or beta for Chrome).
So again this is just a very early demo, but I think this is enough to show the approach can work. Actually we knew this could work already because Mandreel did it,
http://dl.dropbox.com/u/6873971/data/cube2/index.html
But Mandreel is a closed-source compiler that costs money while this demo was made with emscripten, a free open source compiler (that I work on). All the tools and all the code here are open, here is the engine code https://github.com/kripken/BananaBread (hardly any is changed, though) and here is the compiler http://emscripten.org/ So this project will end up with something Sauerbraten and other Cube 2-using projects can use, if they want, unlike Mandreel's tech demo.
Another difference is Mandreel apparently just wanted a tech demo of walking through a small map, that's what they have, whereas the goal in this project is to get all the rest of Sauerbraten working: Rendering other characters, bot AI, weapons, editing (actually a lot of editing already works in the demo!) etc. Basically we aim to get everything working, minus multiplayer since web browsers can't support that yet. But even that should be possible later this year when web browsers get WebRTC support, so we should be able to get the entire game :)
Why is this worth doing? In my opinion, two main reasons:
1. To promote 3D games on the web using open technologies. 3D games are starting to appear on the web, but generally they depend on nonstandard and/or closed source technologies like Flash. This project uses only 100% open and standard technologies, JavaScript and WebGL. We need open technologies to win.
2. To give back to the Sauerbraten community. While running on the web has disadvantages, it does have one huge advantage - all you need is a web browser to run the game. You don't need to download and install an application, which stops most people visiting your game's website from actually playing the game. Imagine if anyone visting the Sauerbraten website could just click and jump right into a game, we could get a lot more people in the community that way!
The current status of this project is that I will continue to work on the rest of the missing features, like model rendering, that are not yet running in the demo. We have permission to use geartrooper's models, and we should be getting some maps from gk, so we should have what we need for some nice results :)
In summary, this is just an early demo, but I think it shows that this can work. There is a lot left to do so help is of course welcome. Btw, this can work for any Cube 2-based project, of course, not just Sauerbraten, so if Red Eclipse, Sandbox etc. want to run on the web as an option we can make that happen too (in fact the porting from C++ to JavaScript is 99% automatic, so almost nothing specific would need to be done), if any project is interested in that then let's work together on it!
- kripken
|
 |
|

Board Index

|
 |
#42: .. |
|
by kripken
on 05/14/2012 22:29
|
 |
|
0.0.7, water and explosions from weapons
http://syntensity.com/static/bb/client_7.html
reply to this message
|
 |
#43: Re: .. |
|
by suicizer01
on 05/14/2012 23:35, refers to #42
|
 |
|
The decals of the explosions are pretty buggy after the first of them disappeared (they aren't fading).
I'm also getting an error message now, which asks me if the script should be stopped.
reply to this message
|
 |
#44: .. |
|
by kripken
on 05/15/2012 03:07
|
 |
|
Yeah, I saw the decals are buggy too. Low priority though, I still need to get a lot of other stuff working like bots.
Does the error message say the script is too slow or something like that?
reply to this message
|
 |
#45: .. |
|
by Honzik1
on 05/15/2012 10:49
|
 |
|
When I press GO!, then Firefox takes 100% of my one CPU. In Chrome I dont have this popup message. I tried Firefox and message popup after pressing GO! and the message ask me: "Stop script" or "Continue".
reply to this message
|
 |
#46: Re: .. |
|
by Razgriz
on 05/15/2012 11:21, refers to #45
|
 |
|
What version are you on?
reply to this message
|
 |
#47: .. |
|
by Honzik1
on 05/15/2012 11:52
|
 |
|
This version: http://syntensity.com/static/bb/client_7.html
Firefox 12.0
reply to this message
|
 |
#48: Re: .. |
|
by GoodOldJacob
on 05/15/2012 12:19, refers to #47
|
 |
|
Try this: http://nightly.mozilla.org/
See if that helps.
reply to this message
|
 |
#49: Re: .. |
|
by Razgriz
on 05/15/2012 13:44, refers to #48
|
 |
|
Or this: http://www.mozilla.org/en-US/firefox/channel/#aurora/aurora-desktop
reply to this message
|
 |
#50: .. |
|
by kripken2
on 05/28/2012 18:19
|
 |
|
v0.0.8
http://syntensity.com/static/bb/client_8.html
* Full hudmodels (arms and weapons, properly connected
* Model animation
* Support for some additional effects, all off by default though. But you can do /waterreflect 1, /waterrefract 1, /glare 1 (note that in Firefox you need to press escape after pressing /, since the search bar pops up).
reply to this message
|
 |
#51: Re: .. |
|
by suicizer01
on 05/28/2012 19:40, refers to #50
|
 |
|
I still manage to keep firing without having to press the attack button (mouse1).
You keep that feature?
Nice to see some animation at models, though no actually playermodels yet (as thirdperson shows)
reply to this message
|
 |
#52: .. |
|
by suicizer01
on 05/28/2012 19:42
|
 |
|
For the people who want to know; setting sensitivity to 15 will make you rotate exactly 1 time.
reply to this message
|
 |
#53: .. |
|
by kripken2
on 05/29/2012 15:41
|
 |
|
It keeps firing like the fire button is stuck? I haven't seen that, not sure what causes it. Do you do anything specific right before it happens?
reply to this message
|
 |
#54: Re: .. |
|
by suicizer01
on 05/30/2012 23:22, refers to #53
|
 |
|
Well, after I get that error message again (probably just takes too long to load, like a server which sends/receives the info too slow), I do the following thing:
1. Click on "GO!"
2. Just take any weapon you want and keep the fire button locked with your hand.
3. Open the menu of Bananabread (escape-button).
4. Move your mouse arrow out of the window.
5. Depress the fire button and you'll notice it keeps firing, as long as you won't hit the fire button again (even when leaving the menu again).
Sorry for the incredible nooby steps, but it's the most clear.
reply to this message
|
 |
#55: .. |
|
by kripken2
on 05/31/2012 17:36
|
 |
|
Thanks! I think I understand what is causing this based on those steps. I should have a fix soon.
reply to this message
|
 |
#56: .. |
|
by kripken2
on 06/03/2012 23:24
|
 |
|
v0.0.9
http://syntensity.com/static/bb/client_9.html
* Thirdperson character models (press 9)
* Blob shadows
* Various bugfixes, including the mouse shooting getting stuck problem that suicizer reported (thanks again for description of the problem).
reply to this message
|
 |
#57: .. |
|
by oibaf
on 06/04/2012 13:01
|
 |
|
I have some problems whith mouse moving and also I see these "could not ...":
Loading level...
read map packages/base/silly.ogz (0.5 seconds)
could not play music: packages/fanatic/6.ogg
could not load texture packages/textures/default.png
could not load texture packages/golgotha/water2.jpg
game mode is efficiency
Efficiency: You spawn with all weapons and armour. There are no items. Frag everyone to score points.
you suicided!
could not load texture packages/icons/frankie.jpg
could not load texture packages/icons/frankie.jpg
Othe tha that it's great!
reply to this message
|
 |
#58: Questions on this engine. |
|
by Kieran
on 06/04/2012 18:51
|
 |
|
Kripken,
How did you manage to automatically compile the opengl rendering to webgl? Or was that done manually. From what I understand they wouldn\'t be compatible.
Will this work with the upcoming improved cube2 engine \'Tesseract?\'
reply to this message
|
 |
#59: Re: Questions on this engine. |
|
by MODS!
on 06/04/2012 23:54, refers to #58
|
 |
|
It won't work with tesseract, nigguh!
reply to this message
|
 |
#60: Re: .. |
|
by kripken2
on 06/05/2012 05:56, refers to #57
|
 |
|
@oibaf
What are the mouse moving problems? Is it lack of mouse lock? (the mouse moves out of the canvas area)
The warnings are expected. I need to add some textures and other stuff.
@Kieran
The translation code is here
https://github.com/kripken/emscripten/blob/master/src/library_gl.js
WebGL is indeed not compatible with OpenGL, we need to emulate a lot of features missing in it.
Tesseract can probably work, it is shader based. I haven't tried though, it might use some OpenGL feature that is hard to emulate in WebGL.
reply to this message
|
 |
#61: .. |
|
by oibaf
on 06/05/2012 11:20
|
 |
|
@kripken2
I noticed that most likely it's so by design and the problem is that I can only move the view of less than 180° with the mouse.
Also there are some green textures, I suppose this is due to the "could not load texture ..." reported previously:
http://img543.imageshack.us/img543/6239/sauerjs.png
(FF 12 on Ubuntu 12.04 here + driver from mesa git under a r300)
reply to this message
|
 |
 |
|

Board Index

|
 |