User Tools

Site Tools


proton:html5_setup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
proton:html5_setup [2015/09/09 05:16] sethproton:html5_setup [2015/09/09 07:15] seth
Line 5: Line 5:
 Well, we all know by now that Flash is dead. HTML5 (which is really Javascript and WebGL) is the new way to get your games and apps onto the web in way that is safe for players. Nobody wants to download .exe files and get viruses anymore, so this is a good way to go. Well, we all know by now that Flash is dead. HTML5 (which is really Javascript and WebGL) is the new way to get your games and apps onto the web in way that is safe for players. Nobody wants to download .exe files and get viruses anymore, so this is a good way to go.
  
-You will take a speed hit and you don't get full access to the user's hardware and networking, but that's the price you pay. You can't do direct socket/UDP access like you used to (there is a new thing called websockets but they can't be used to communicate with standard sockets), but it is still possible to do networked games with some work arounds. If you need to read files/data (you CAN post/get data) from a web page, you need to setup the server itself to allow access if the original app wasn't downloaded from the same domain. Annoying, but without this people could basically DDOS any site by getting a lot of people to simply open a webpage.+{{:proton:rtsimpleapp_html5.png?400|}} 
 + 
 +You will take a speed hit and you don't get full access to the user's hardware and networking, but that's the price you pay.  
 + 
 +You can't do direct socket/UDP access like you used to (there is a new thing called websockets but they can't be used to communicate with standard sockets), but it is still possible to do networked games with some work arounds. If you need to read files/data (you CAN post/get data) from a web page, you need to setup the server itself to allow access if the original app wasn't downloaded from the same domain. Annoying, but without this people could basically DDOS any site by getting a lot of people to simply open a webpage.
  
 The good news is getting your Proton SDK based games to export to HTML5 is very easy and only requires setting up the makefile and maybe a couple lines in your App.cpp file. The good news is getting your Proton SDK based games to export to HTML5 is very easy and only requires setting up the makefile and maybe a couple lines in your App.cpp file.
Line 74: Line 78:
 === Tips and gotchas === === Tips and gotchas ===
  
-GL emulation is handled by emscripten with the -s LEGACY_GL_EMULATION=1. It's not that great. It works fine for 2D games but expect features to be missing for any 3d stuff you're porting. My game Mindwall is playable, but the lighting and color is wrong.  The way forward here is to use GLES 2+ which it can emulate with WebGL much better, but I'm not sure if I want to do that with Proton in general or not right now.+GL Limitations: GL emulation is handled by emscripten with the -s LEGACY_GL_EMULATION=1. It's not that great. It works fine for 2D games but expect features to be missing for any 3d stuff you're porting. My game Mindwall is playable, but the lighting and color is wrong.  The way forward here is to use GLES 2+ which it can emulate with WebGL much better, but I'm not sure if I want to do that with Proton in general or not right now. 
 + 
 +Networking: if you run the .html locally but try to read/write highscores to scores.php on your webserver it's going to fail.  You'll have to actually upload your files then run it from the actual domain name for it to work, or [[http://www.html5rocks.com/en/tutorials/cors/|check out what Cross-Origin Resource Sharings is]] and set up your server to accept stuff from your home IP address. Also, having the www in your url or seems to matter too when it compares domain names. 
 + 
 +Proton's NetHTTP class to get/post to web sites is emulated behind the scenes with NetHTTP_HTML5.cpp, a special version for emscripten that uses emscripten_async_wget2_data. No code changes necessary. 
 + 
 +Screen size:  This can be overridden in App::PreInitVideo by changing the globals g_winVideoScreenX and Y. (You may need to declare them as extern first (ie, extern int g_winVideoScreenX; extern int g_winVideoScreenY; yeah, I know, the whole thing is weird but I'm afraid of changing anything now due to backwards compatibility) By default, in HTML5Main.cpp it gets set to this: 
 + 
 +<code>g_winVideoScreenX = 480; 
 +g_winVideoScreenY = 320;</code> 
 + 
 +  
 +There is some weirdness to work out with screen scaling and mouse click locations turning wonky when sizes are changed in realtime. Right now I'm using enterSoftFullscreen(EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT, EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF, EMSCRIPTEN_FULLSCREEN_FILTERING_NEAREST) but these can be changed for different behaviors, tweak as needed for now. (it's in the same file) 
 + 
 +Size: There is also the issue of a 102 kb default .html file that is generated that is doing stuff we probably don't need, I've looked in there and it is possible to remove a lot of it (the emscripten logo is in there for instance), hopefully emscripten html generator will have more options in the future, otherwise you can hand edit it and adjust your batch files I guess.  
  
-Networking if you run the .html locally but try to read/write highscores to scores.php on your webserver it'going to fail.  You'll have to actually upload your files then run it from the actual domain name for it to work, or [[http://www.html5rocks.com/en/tutorials/cors/|check out what Cross-Origin Resource Sharings is]] and set up your server to accept stuff from your home IP address.+Compression Now, you may say that 1,138 kb .js file for RTBareBones is big, but fear not - it's actually only 264 KB when you run it from my link above.
  
 +What is this witchcraft? The server is compressing it! You can [[http://www.whatsmyip.org/http-compression-test/?url=aHR0cDovL3d3dy5ydHNvZnQuY29tL1JUQmFyZUJvbmVzLmpz|check it here]].
proton/html5_setup.txt · Last modified: 2024/01/13 04:55 by seth