Structure of the WebGL examples
We have improved the structure of the code examples in this chapter. As the complexity of our WebGL applications increases, it is wise to have a good, maintainable, and clear design. We have left this section at the end of the chapter so you can use it as a reference when working on the exercises.
Just like in previous exercises, our entry point is the runWebGLApp
function which is called when the page is loaded. There we create an instance of WebGLApp
, as shown in the previous diagram.
WebGLApp
This class encapsulates some of the utility functions that were present in our examples in previous chapters. It also declares a clear and simple life cycle for a WebGL application. WebGLApp
has three function hooks that we can map to functions in our web page. These hooks determine what functions will be called for each stage in the life cycle of the app. In the examples of this chapter, we have created the following mappings:
configureGLHook
: which points to theconfigure...