Click here to Skip to main content
15,898,134 members
Articles / STL

Reducing Game Start Up Time

Rate me:
Please Sign up or sign in to vote.
3.50/5 (2 votes)
25 Oct 2010CPOL 10.2K   4
Two tips to reduce game start up time

A lot of game developers consider the start-up time of a game to be of little importance. Unfortunately, the truth is that users do not like looking at the hourglass. So, here are two tips to reduce start-up time.

1. Use Targa instead of PNG

PNGs take several times longer to decode than compressed Targa. I think it’s around 5 times slower. (I once made some measurements on the iPhone, but I lost the figures <duh>). On the other hand, compressed Targa files are about 40% bigger, but disk space usually isn't that critical. You can use the code here to decode targa files: http://dmr.ath.cx/gfx/targa/.

An interesting side effect of this optimization is that it also reduces development time. Every time you start up the debugger, it has to decode all those 1024×1024 textures, before you can begin.

2. Read Files by Blocks, Not Word by Word

Preferably, read the whole file in one go. This is how you do it with C code:

C++
FILE* pFile;
pFile = fopen(fileName.c_str(), "rb");
if (pFile == NULL) return;
fseek(pFile, 0, 2 /* SEEK_END */);
fileSize = (int)ftell(pFile);
fseek(pFile, 0, 0 /* SEEK_SET */);
pBuffer = new char[filesize];
int bytesRead = (int)fread(pBuffer, fileSize, 1, pFile);
fclose(pFile);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Astronautz
Spain Spain
After working in the software industry for many years, I've started my own games company that specialises in strategy games for mobile platforms.

Comments and Discussions

 
GeneralMy vote of 3 Pin
Jeff R.30-Dec-10 5:28
professionalJeff R.30-Dec-10 5:28 
GeneralComments Pin
Mr Crisp2-Nov-10 22:28
Mr Crisp2-Nov-10 22:28 
I've done some work on load times on a PS2 game.

Point 2 was key to improved load times for us. We had a large number of .txt script files, image files, config files etc loaded one at a time. I took the solution to the extreme! What I did was make an memory image after loading. Save that, and then for future loading, load that memory image as a single file directly into memory... So getting around open load times, decompression time, memory allocation and pretty much everything that takes time. For release this made over a factor of 3 speed up, though mostly useless during developement as any data change meant you had to make a new memory image file.

Point 1, if you have load thread, then image decompression can be done at the same time as loading other data, so its better to have higher compression for faster loading.
GeneralRe: Comments Pin
ed welch3-Nov-10 4:15
ed welch3-Nov-10 4:15 
GeneralRe: Comments Pin
Mr Crisp3-Nov-10 6:11
Mr Crisp3-Nov-10 6:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.