After having browsed a bunch of emscripten demos, I thought I 'd try porting a game and try to use this technology.
First, I tried onescripter, because there is a fatestaynight that can be compiled and run in hand.
- Add the new platform: emscripten in the project configuration, and select compile as executable HTML
- The compilation prompts that bzlib. H is missing and the libbz2 Project (Open Source) is added. Note that this requires compiling the. BC Library (equivalent to. Lib)
- Compile the SDK again and check whether the dependent database is correct. If the sdl_cd function cannot be found, it is understandable that the Web cannot access the optical drive. Use the # If emscripten macro to isolate unsupported SDL feature codes.
- After compilation, you can run the script, but the system prompts that the script file cannot be found. In the past, emscripten had a lot of restrictions on file IO. For details, refer to: filesystem guide.
- The first method is simple and crude. It packs all dependent files into one. the data file is downloaded when the page is loaded, and the game is started after the download. however, all data is stored in the memory at this time. Therefore, all fopen functions actually access the Virtual File System in the memory. experiments show that for a fatestaynight game with GB resources, this method will cause the browser to crash -_-
- The second method should be the one floh mentioned in the PPT, similar to the asynchronous file download method. Because it is just an experiment, it has not been tried yet.
- Use the -- preload-File Link option to package the resource folder into. Data to see the effect first (use another relatively small game Resource: tsukihime. otaku understands)
- When the page is opened, it does not respond. CTRL + Shift + J open the chrome debugging window and find that the browser does not allow access to the file: // protocol path.
- I found a green HTTP server tool HFS on the Internet, accessed the page through the HTTP server, and finally the file can be read. After the page is loaded, a progress bar will display the download progress.
- Run, the debugging window shows that the mix_xxxx function is not implemented, nm, is there such a pitfall ...... use # If emscripten shielding, do not play the sound first
- Run the command again and prompt that some sdl_xxxx functions cannot be found. Give up!
Then I tried sdlpal (the famous fairy sword 95), and the compilation was no problem. During the runtime, I was prompted that the implementation of an SDL function could not be found. this is really speechless. Why can't you find the link for success? Bai was excited that both SDL games ended in failure. after reading the libraries in the SDK, it seems that OpenGL ES, openal, SDL, etc. bullet also has a third-party port. therefore, for commercial use, the selection of third-party libraries is much worse than that of NaCl. Now, we can make a demo. So we can say that the SDL of emscripten is not complete. In actual use, it is estimated that some window/input messages will be replaced. valve mentioned some experience in porting to Linux on GDC. Specifically, SDL is a good alternative for cross-platform communication, if you are too lazy to implement a program framework, window, keyboard, and mouse message for every platform, Use SDL, firefox is much faster than chrome. it's really Mozilla's own child ~