Loading texture assets asynchronously
All our demos up to this point have preloaded all the assets at startup, before anything can be rendered. This is okay for applications where the size of the data is small, and everything can be loaded in an instant. Once our content gets into the territory of gigabytes, a mechanism would be desirable to stream assets as required. Let's extend our demos with some basic lazy-loading functionality to load textures while the application is already rendering a scene. Multithreading will be done using the Taskflow library and standard C++14 capabilities.
Getting ready
We recommend revisiting the Multithreading with Taskflow recipe of Chapter 2, Using Essential Libraries.
The source code for this recipe can be found in Chapter10/GL04_LazyLoading
.
How to do it...
To make things simple, the idea behind our approach is to replace the GLSceneData
class, which handled all scene loading so far, with another class called GLSceneDataLazy
...