Creating a WebGL application
At this point, we have covered the basic topics that you need to be familiar with in order to create a WebGL application. These topics have been implemented in the infrastructure code that we have iteratively built up throughout the book. Let's see what we have learned so far.
In Chapter 3, Lights!, we introduced WebGL and learned how to enable it in our browser. We also learned that WebGL behaves as a state machine and that we can query the different variables that determine the current state using gl. getParameter
.
After that, we studied in Chapter 2, Rendering Geometry, that the objects of a WebGL scene are defined by vertices. We said that usually we use indices to label those vertices so we can quickly tell WebGL how to 'connect the dots' to render the object. We studied the functions that manipulate buffers and the two main functions to render geometry drawArrays
(no indices) and drawElements
(with indices). We also learned about the JSON format to represent...