Game Development Reference
In-Depth Information
Chapter 8
Loading and Caching Game
Data
Once you get a nice 3D model or sound, how do you actually get it into your game?
Most game topics present code examples where the game loads X, WAV, or MP3
files directly. This doesn
t work in real games. Real games have tens of thousands of
these files and other bits of data. They might not fit into memory at the same time,
either. When you see a detailed environment in Gears of War, you can bet that it fills
memory nearly to the last bit, and the act of walking into another room or building
needs some way of kicking out unused assets and bringing in the new, and doing it in
a way that seems completely transparent to the player. So how does this really work?
Take a look at Figure 8.1.
Games usually pack selected bits of game data into a small number of files, often
called a resource file. By the way, just in case I haven
'
t mentioned it, I tend to use
the terms game assets and game resources to mean the same thing they are all
game data. Art, animations, sounds, 3D meshes, and map levels are all game assets.
These files usually map one-to-one with an entire game level. When you see a load-
ing screen, you are likely witnessing the game reading just enough of the resource
files to begin playing the game.
Each game resource you use must be converted to the smallest possible format that is
supported by the hardware, taking care to keep the quality at the right level. This is
pretty easy for sounds, since you can easily predict the quality and size delta of a
44KHz stereo WAV versus an 11KHz mono WAV stream. Textures are trickier to
'
195
 
 
 
Search WWH ::




Custom Search