- Hands-On Game Development with WebAssembly
- Rick Battagline
- 226字
- 2021-06-24 13:41:08
Compiling sprite.html
We can now compile our sprite WebAssembly app by using the emcc command. You will need the sprites folder from the Chapter02 folder on GitHub. After you have downloaded the sprites folder and placed it in your project's folder, you can compile the app with the following command:
emcc sprite_move.c --preload-file sprites -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS=["png"] -o sprite_move.html
It is important to remember that the app must be run from a web server, or using emrun . If you do not run the app from a web server, or use emrun, you will receive a variety of errors when the JavaScript glue code attempts to download the WASM and data files. You should also know that IIS requires additional configuration in order to set the proper MIME types for the .wasm and .data file extensions.
We are still using the --preload-file flag, however, this time we are passing in the sprites folder instead of the fonts folder. We will continue to use the -s USE_SDL=2 flag and will be adding the -s USE_SDL_IMAGE=2 flag, which will allow us to use images with SDL that are an alternative to the .bmp file format.
To tell SDL_IMAGE which file format to use, we pass in the png format using the following -s SDL2_IMAGE_FORMATS=["png"] flag:

Figure 4.3: Screenshot of sprite_move.html
推薦閱讀
- 用“芯”探核:龍芯派開發(fā)實(shí)戰(zhàn)
- FPGA從入門到精通(實(shí)戰(zhàn)篇)
- Effective STL中文版:50條有效使用STL的經(jīng)驗(yàn)(雙色)
- 硬件產(chǎn)品經(jīng)理成長手記(全彩)
- 基于ARM的嵌入式系統(tǒng)和物聯(lián)網(wǎng)開發(fā)
- 深入淺出SSD:固態(tài)存儲核心技術(shù)、原理與實(shí)戰(zhàn)(第2版)
- Mastering Manga Studio 5
- CC2530單片機(jī)技術(shù)與應(yīng)用
- Practical Machine Learning with R
- 單片機(jī)系統(tǒng)設(shè)計(jì)與開發(fā)教程
- 3D Printing Blueprints
- The Artificial Intelligence Infrastructure Workshop
- Mastering Machine Learning on AWS
- FPGA實(shí)驗(yàn)實(shí)訓(xùn)教程
- 計(jì)算機(jī)電路基礎(chǔ)(第2版)