in order texture loading


Lets look at an in-order example of texture loading. Which will take the previous code and refactor it for many different textures.


The whiteboard example below is identical on the previous page. We will implement it now exactly.

whiteboard example of in order texture loading, could also load then write before moving on to the next

This is the main block of code for reading and writing textures in order. All the textures are loaded, then all the textures are written.


On my system, with 6 texture folders, each containing 5 textures all are 4k, although some have only 1 channel, it takes about 370,000ms(~6.2min) to finish.

A texture struct is created that holds all of the texture.

this code is almost identical to the previous page we just encapsulated it into a struct, could also use a class if you prefer. the static id could be used to keep track of the textures being loaded.


The parameterized constructor takes in a number(num) and type(type). The number corresponds to the texture folder, and the type is the type of texture.


There are 5 different texture types for each model in my game engine. The textureFiles vector holds this info.

diffuse(also albedo), height, metallic, normal, roughness.


You can use whatever you like of course.