Game Development Reference
In-Depth Information
Now, let's look at the constructor inside the source file:
The first line after the #include statements initializes the static pointer sInstance
to nullptr (which is null or 0). It is a good practice to set a pointer to nullptr just
after we declare it as we can check later on if it is valid or not. This is exactly what we do
in the constructor. We call the assert macro which checks whether an expression is
true . If it is, nothing happens. However if it's false , the macro calls abort() , which
terminates the program. This check prevents more than one instance of the class to be cre-
ated, which is exactly what we want. After we've made sure that this is the only instance,
we will set the static pointer to the this instance.
Here is the AssetManager::GetTexture() implementation:
Search WWH ::




Custom Search