Game Development Reference
In-Depth Information
GCC_ERROR(
Failed to initialize resource cache! Are your paths set up
correctly?
);
return false;
}
m_ResCache->RegisterLoader(CreateWAVResourceLoader());
m_ResCache->RegisterLoader(CreateOGGResourceLoader());
m_ResCache->RegisterLoader(CreateDDSResourceLoader());
// Note a few more loaders continue past here...
This code creates the ResCache object and initializes the resource cache to 50 mega-
bytes. It also creates an object that implements the IResource interface.
Choosing the size of your resource cache has everything to do with what kind of
computer you expect your players to have. Players of the latest game from Crytek
are going to have way more memory than my mother-in-law
an old
laptop I gave her about four years ago. After you choose the size of your cache, you
should be cautious about how that memory is being used as you stuff in more tex-
tures, sounds, animations, and everything else. Once you run out, your game will
stop performing like it should as it suffers cache misses. Console programmers have
a harsher climate
'
s computer
if they run one byte over, their game will simply crash.
'
You
ll notice the calls to RegisterLoader() . A resource cache can contain many
different types of resources, such as sounds, music, textures, and more. The resource
cache needs to know how each one of these files types is read and converted into
something the game engine can use directly. The process of registering a loader
associates a specific loader class with a file type. You
ll learn more about how that
works in the Chapter 8 and see how each of these loaders is coded throughout the
book.
'
How Much Longer?!?
It seems like every game I work on has the same cycle when it comes to load
optimization. At first, things are just fine because we
re loading small sets of
artwork and parsing small XML files. As artists and designers add content to
the game, the load times start to grind to a halt, and before too long, our
game is taking 5
'
10 minutes just to load the test level! Some programmers
usually spend a few days optimizing the data loading to get it to a decent
time again, but it will inevitably creep back up. It
-
'
s an interesting dance.
Loading Text Strings
Text strings that are presented to the player should never be hardcoded. Whatever
language you speak, there are more people out there who speak other languages!
This is handled easily by putting all your text strings into a data file that is easy to
 
 
Search WWH ::




Custom Search