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

Summary

In this chapter, we discussed the Emscripten minimal shell HTML file, what its various components are, and how they work. We also wrote about what parts of the file we can do without, if we are not using our shell to generate canvas code. You learned about the Module object, and how it is the interface that uses the JavaScript glue code to tie the JavaScript in our HTML and our WebAssembly together. We then created a new WebAssembly module that contained functions we exported to allow JavaScript to use Module.cwrap to create JavaScript functions we could then call from our DOM that executes our WebAssembly functions.

We created a brand new HTML shell file that used some of the Module code from the Emscripten minimal shell, but rewrote the HTML and CSS of the original shell almost entirely. We were then able to compile that new C code and HTML shell file into a working WebAssembly app that was able to call WebAssembly functions from JavaScript, as well as call JavaScript functions from WebAssembly.

We discussed the benefits of using the HTML5 canvas element, and the differences between immediate and retained mode graphics. We also explained why it makes sense for games and other graphics-intensive tasks to use immediate mode instead of retained mode.

We then created a shell file to make use of the HTML5 canvas element. We added JavaScript code to draw an image to the canvas and wrote C code that used WebAssembly to modify the position of that image on the canvas every frame creating the appearance of a moving spaceship on the HTML5 canvas.

In the next chapter, we will introduce you to WebGL, what it is, and how it improves graphics rendering on the web.

主站蜘蛛池模板: 新绛县| 钟祥市| 托克逊县| 资讯 | 武安市| 长泰县| 哈巴河县| 霸州市| 杨浦区| 济阳县| 甘肃省| 景谷| 南京市| 全椒县| 南宁市| 临颍县| 凭祥市| 长宁区| 景德镇市| 武陟县| 睢宁县| 屏南县| 大渡口区| 崇州市| 惠东县| 天台县| 扎赉特旗| 和顺县| 和顺县| 宝坻区| 鲁甸县| 凯里市| 贺州市| 嘉定区| 隆子县| 黄梅县| 出国| 荥经县| 嘉祥县| 玉屏| 孝感市|