home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


BananaBread: Porting Cube 2 to the Web

by kripken on 05/04/2012 00:02, 143 messages, last message: 11/10/2016 01:26, 82653 views, last view: 04/18/2024 22:25

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    Go to next 20 messagesGo to last 20 messages

#1: ..

by Razgriz on 05/04/2012 09:20

Firefox Aurora also works, so i can avoid the Nightly which is notorious for stupid BEX errors.

Funnily, this tech demo of sauer still plays a lot smoother than minecraft on a flat map. Win Win.

reply to this message

#2: ..

by Zorg on 05/04/2012 10:49

Works on Chrome version 18 on craqppy hardware with 2 fps. Great work!

reply to this message

#3: ..

by GoodOldJacob on 05/04/2012 17:42

This is amazing!

reply to this message

#4: Viable Gem

by Zamwa on 05/04/2012 18:02

desktop,
<Firefox 4.0 Beta 6
App Version: 4.0.1
GRE Version: 2.0.1>
OS Name : Windows 8, Ubuntu (not tested on partitioned Ubuntu)
Target CPU : x86
Processor : AMD Phenom II X2 545
Ram : 4GB
Graphics : GeForce 9800 GTX+

Incredible so far 66fps from syntensity is viable for gaming on My gear with some split second pauses!

reply to this message

#5: ..

by Razgriz on 05/04/2012 19:10

wow, why are you still on a firebox 4 beta? :P

reply to this message

#6: ..

by Q009 on 05/04/2012 19:21

Works just fine on Chrome 18

reply to this message

#7: ..

by kripken on 05/04/2012 21:25

Does mouselock work for anyone in chrome? That is, in fullscreen you should not see the OS mouse, and if you keep moving the mouse to one side, it should keep moving the orientation in the game, and not stop when the mouse exits the canvas. I've only gotten this to work in Firefox 15 but not in Chrome 20.

If this works for people in Chrome 18 then I guess it is a regression in Chrome and we should file a bug.

reply to this message

#8: Re: ..

by Q009 on 05/04/2012 21:35, refers to #7

Well, it doesn't lock mouse inside and keyboard events don't work as well :P

reply to this message

#9: ..

by kripken on 05/04/2012 21:41

Ok thanks, then that's what I saw too, chrome doesn't do keyboard in fullscreen (well, not wasd - space works), and not mouselock. I'll investigate more.

reply to this message

#10: ..

by suicizer01 on 05/05/2012 00:27

Some bugs:
- It freezes every time I try to type in something in the console line.

- It keeps shooting when a gui pops up and still clicking.

If you want to make it a stand-alone game with different themes, maybe the texture packs and models which I've posted on quadropolis help.

reply to this message

#11: ..

by kripken on 05/05/2012 01:11

I have a fix for the freezing console line bug, will show up in the next update in a day or two.

Probably some input handling bug if it keeps shooting like that, I need to investigate that issue.

Cool about the models and textures packs, any in particular that you recommend? And how are they licensed?

reply to this message

#12: Re: ..

by suicizer01 on 05/05/2012 02:33, refers to #11

Just for you, here they are.
The license is notified on the node, but be sure to check the read-me file also.
If a read-me isn't matching your temptations, just take contact with Yves Allaire. He often is a cool guy about such things.

I still have to notify, there are several texturepacks which could be updated (I probably will make some time for it soon).

dsi texturepack (updated a while ago)
http://www.quadropolis.us/node/2780

e6 texturepack (updated a while ago also)
http://www.quadropolis.us/node/2778

e7 texturepack (still need to tweak it a little bit before the update is complete)
http://www.quadropolis.us/node/2790

e8 texturepack (still have to start updating this one)
http://www.quadropolis.us/node/2859

eX texturepack (doesn't need to be updated. It's a very good replacement texture-set for the lunaran textures, or as add on).
http://www.quadropolis.us/node/2792

the lost textures of ikbase texturepack
http://quadropolis.us/node/3107

soc's terrain texturepack
http://quadropolis.us/node/3083

roof texturepack
http://quadropolis.us/node/3223

FBP's roof enhancement texturepack
http://quadropolis.us/node/3222

huge modelpack (could also use a small update)
http://quadropolis.us/node/3142

enhanced gameplay models
http://www.quadropolis.us/node/3311

gutter_1 modelpack
http://quadropolis.us/node/3209

nobiax tropical plants (enhancements of the models are inside a comment of me)
http://quadropolis.us/node/3216

quakish modelpack (this one definitely needs to be updated)
http://quadropolis.us/node/2901


I'm sure I've posted some more, but can't find them right now.

reply to this message

#13: Re: ..

by suicizer01 on 05/05/2012 02:35, refers to #12

Almost forgot to change,
If it's an enhancement or a redistribution; the original author is (almost) always notified. Contact him if it the license is against your will.

reply to this message

#14: ..

by kripken on 05/05/2012 02:41

Thanks suicizer!

reply to this message

#15: ..

by kripken on 05/05/2012 03:27

Uploaded version 0.0.2. control-shift-R to reload if you have it in your cache already. You should see "version 0.0.2" above the canvas.

Fixes some bugs, and adds sound support. Sounds works in Firefox but not in Chrome due to a bug in Chrome, code.google.com/p/chromium/issues/detail?id=124926 hopefully they'll fix it soon.

reply to this message

#16: ..

by Quin on 05/05/2012 07:40

Keyboard and mouse lock doesn't work in Chrome v20, and I get shader errors when loading it.

All of the content in Red Eclipse is free to use, being CC-BY-SA (or better/similar), if that helps you at all.

Very interested in this myself, but I'm quite busy with the real world at the moment to give it my proper attention. Keep working on it and I will take a better look at it at a later date :)

reply to this message

#17: Re: ..

by suicizer01 on 05/05/2012 17:51, refers to #14

Here some texturepack which I forgot.

Philip Klestav texturepack 2 (too bad no height-mapped textures)
http://quadropolis.us/node/3163

Thor2 (GreGor) textures and models
http://quadropolis.us/node/1943

Hazel texturepack
http://quadropolis.us/node/1970

Marathon texturepack
http://quadropolis.us/node/1991

Thunderbird mapmodel
http://quadropolis.us/node/3338

DFS mapmodels
http://quadropolis.us/node/346

Hellpig2
http://quadropolis.us/node/1507

Trapdoor mapmodel
http://quadropolis.us/node/1079

Konion mapmodel
http://quadropolis.us/node/272

Cartoonish mapmodels
http://quadropolis.us/node/2529

Some more cartoonish mapmodels
http://quadropolis.us/node/2499

Yet even more cartoonish mapmodels
http://quadropolis.us/node/2520

Cartoonish duck-grenades
http://quadropolis.us/node/3084

That's it for now...

reply to this message

#18: ..

by Zorg on 05/06/2012 02:06

Version 0.0.2 on Chrome v18:
- WASD not working, space working fine
- mouselock not working
- OS mouse has offset to game mouse in main menu, about 1/3 screensize diagonal
- 60 fps on my laptop, great!

reply to this message

#19: ..

by Zorg on 05/06/2012 02:10

Correction: Offset between OS mouse position and game mouse position depends on entry point of the mouse onto the game canvas. Same behavior in fullscreen mode.

reply to this message

#20: ..

by suicizer01 on 05/06/2012 02:14

tested it again with Firefox (I have seriously no idea which version. How do I check out in the first place?), getting around 61fps.

Nice to see some hudguns, but the hand of the pistol doesn't seems to have the correct skin (correct me if I'm false).

Too bad options has been disabled again.

reply to this message

   Board Index    Go to next 20 messagesGo to last 20 messages


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2024
website by SleepwalkR © 2001-2024
53688041 visitors requested 71455324 pages
page created in 0.080 seconds using 10 queries
hosted by Boost Digital