User talk:Rppowell

From GPWiki

Files:GUITutorial_warn.gif The Game Programming Wiki has moved! Files:GUITutorial_warn.gif

The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server.

However, the GPWiki forums are still active! Come say hello.

I enjoyed your new SDL article, Rppowell! I'm sure many people will find it helpful... using zlib with SDL_RWops is a great idea.

Welcome to GPWiki! :)

--Ryan Clark 19:57, 2 September 2006 (EDT)

zlib & SDL_RWops

This entry using SDL_RWops and zlib a bit limited in that you can only get SDL_RWops from a file. I'm trying to figure out how to get a SDL_RWops from a SDL_RWops of a zipfile, but I'm having problems with zlib's function calls.

I can copy a zip file into memory, call SDL_RWFromMem() on it to create a SDL_RWops, and then parse though the data to find the chunk of data that represents the compressed info. I get an error 'Z_DATA_ERROR' when I call zlib's uncompress() function.

compresseddata = new Uint8[compressedsize];
uncompresseddata = new Uint8[uncompressedsize];
blocks = SDL_RWread(rw, data, compressedsize, 1);
if (blocks != 1) {
	printf("Error reading data.\n");
	exit(1);
}
 
unsigned long size = uncompressedsize;
ret = uncompress( uncompresseddata, &size, compresseddata, compressedsize );
printf("zlib::uncompress returns %d\n", ret);

Once I figure out how to get zlib to decompress the data, all that needs to be done is call SDL_RWFromMem() on it. Any help with using zlib would be appreciated.

-rppowell