- Hands-On Game Development with WebAssembly
- Rick Battagline
- 274字
- 2021-06-24 13:41:04
2D canvas to WebGL
Let's begin by copying out canvas code from the Chapter02 directory into the Chapter03 directory. Next, we are going to rename the canvas_shell.html file to webgl_shell.html. We will rename canvas.css to webgl.css. Lastly, we will rename the canvas.c file webgl.c. We will also need to make sure that we copy over the spaceship.png file. We are not going to be changing the webgl.css file at all. We will make the most significant changes to the webgl_shell.html file. There is a lot of code that must be added to make the switch from 2D canvas to WebGL; almost all of it is additional JavaScript code. We will need to make some minor tweaks to webgl.c so that the ship's position in the MoveShip function reflects the WebGL coordinate system with its origin in the center of the canvas.
Before we begin, I would like to mention that this WebGL code is not meant to be production ready. The game we will be creating will not use WebGL in the way that I am demonstrating here. That is not the most efficient or scalable code. What we are writing will not be able to render more than one sprite at a time without significant changes. The reason I am walking you through what it takes to render 2D images using WebGL is to give you an idea of what is going on behind the scenes when you are using a library like SDL. If you do not care how things work behind the scenes, no one will fault you for skipping ahead. Personally, I always prefer knowing a little more.
- 筆記本電腦使用、維護與故障排除實戰
- 用“芯”探核:龍芯派開發實戰
- 深入理解Spring Cloud與實戰
- 硬件產品經理手冊:手把手構建智能硬件產品
- 微軟互聯網信息服務(IIS)最佳實踐 (微軟技術開發者叢書)
- Spring Cloud微服務架構實戰
- 龍芯自主可信計算及應用
- LPC1100系列處理器原理及應用
- Mastering Quantum Computing with IBM QX
- Drupal Rules How-to
- Zabbix 4 Network Monitoring
- Hands-On One-shot Learning with Python
- DevOps實戰:VMware管理員運維方法、工具及最佳實踐
- FPGA進階開發與實踐
- 電腦軟硬件維修寶典