官术网_书友最值得收藏!

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
主站蜘蛛池模板: 垦利县| 华阴市| 隆尧县| 永善县| 荥经县| 晋城| 株洲县| 东源县| 竹北市| 罗田县| 墨江| 天祝| 理塘县| 宁蒗| 沧州市| 商丘市| 沙坪坝区| 孟州市| 恭城| 施甸县| 乌拉特中旗| 太白县| 蒲城县| 大竹县| 肃宁县| 洛扎县| 库尔勒市| 文成县| 郑州市| 襄汾县| 分宜县| 衡南县| 兰州市| 天气| 盐津县| 任丘市| 灵武市| 普定县| 丽水市| 托克托县| 台南市|