Loading texture data from a file
Texturing is a commonly used technique. It allows us to place an image on the surface of an object in a similar way to how we put wallpaper on walls. This way we don't need to increase the geometric complexity of a mesh, which would be both too complex for the hardware to process it, and would use too much memory. Texturing is simpler to handle and allows us to achieve better, more convincing results.
Textures can be generated procedurally (dynamically in code), but usually their contents are read from images or photos.
Getting ready
There are many different libraries allowing us to load contents of images. All of them have their own specific behaviors, usages, and licenses. In this recipe, we will use a stb_image
library created by Sean T. Barrett. It is very simple to use, yet supports enough image formats to start developing a Vulkan application. And one of its main strengths is that it is a single header library, all its code is placed in just one header...