proton:html5_setup
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
proton:html5_setup [2015/09/09 02:21] – created seth | proton:html5_setup [2018/04/12 01:24] – seth | ||
---|---|---|---|
Line 1: | Line 1: | ||
====Compiling the examples for HTML5 with Enscripten from Windows ==== | ====Compiling the examples for HTML5 with Enscripten from Windows ==== | ||
+ | |||
+ | ====WARNING: | ||
== About and situation == | == About and situation == | ||
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, but it is still possible to do networked games with some work arounds. If you need to read files/data from a web page, you need to setup the server itself to allow access. Annoying, without this, people could basically DDOS any site by getting a lot of people to simply open a webpage. | + | {{: |
+ | |||
+ | 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 | ||
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 25: | Line 31: | ||
From time to time, you should probably [[https:// | From time to time, you should probably [[https:// | ||
+ | |||
+ | == Your first compile: RTBareBones == | ||
+ | |||
+ | Actually we could use RTConsole as it's simpler (no loop) but hey, let's do this. | ||
+ | |||
+ | In file explorer, navigate to your <proton checkout dir> | ||
+ | |||
+ | Double click build_release.bat. | ||
+ | |||
+ | Note that the makefile must include %SHARED%\html5\HTML5Main.cpp and %SHARED%\html5\HTML5Utils.cpp, | ||
+ | |||
+ | If your app uses audio (RTBareBones doesn' | ||
+ | |||
+ | See that SET DEBUG=0? | ||
+ | |||
+ | See the " | ||
+ | |||
+ | RTSimpleApp builds the identical way. | ||
+ | |||
+ | If everything worked, you'll see RTBareBones.html and RTBareBones.js in same directory as the batch files, at 102KB and 1,138KB sizes. | ||
+ | |||
+ | |||
+ | == Source code changes == | ||
+ | |||
+ | For RTSimpleApp I really only changed one thing: | ||
+ | |||
+ | I added CLEAR_GL_ERRORS(); | ||
+ | |||
+ | For audio, use AudioManagerSDL. | ||
+ | |||
+ | These means in your App.cpp, | ||
+ | |||
+ | change | ||
+ | |||
+ | < | ||
+ | #include " | ||
+ | AudioManagerSDL g_audioManager;</ | ||
+ | |||
+ | |||
+ | to | ||
+ | |||
+ | < | ||
+ | #include " | ||
+ | AudioManagerSDL g_audioManager;</ | ||
+ | |||
+ | and you should be golden. | ||
+ | |||
+ | === Tips and gotchas === | ||
+ | |||
+ | GL Limitations: | ||
+ | |||
+ | 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:// | ||
+ | |||
+ | Proton' | ||
+ | |||
+ | Screen size: This can be overridden in App:: | ||
+ | |||
+ | < | ||
+ | g_winVideoScreenY = 320;</ | ||
+ | |||
+ | |||
+ | There is some weirdness to work out with screen scaling and mouse click locations turning wonky when sizes are changed in realtime. By default it will start in a window, but you can actually get it to start in fullscreen by default by uncommenting enterSoftFullscreen(EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT, | ||
+ | |||
+ | 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. | ||
+ | |||
+ | 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:// |
proton/html5_setup.txt · Last modified: 2024/01/13 04:55 by seth