| 1 |
WARNING: |
| 2 |
The following instructions are outdated. |
| 3 |
They refer back to 16. Dezember 2002 with zziplib version 0.10.66. |
| 4 |
Most things refer to MSVC which have a different README |
| 5 |
(and there are msvc project files being shipped along) |
| 6 |
The rest is mainly an example program that you can use as a |
| 7 |
boilerplate in your souce code - may be just copy and use. |
| 8 |
|
| 9 |
--------------------------------------------------------------------- |
| 10 |
16122002, [email protected], Using the zziplib library with SDL |
| 11 |
|
| 12 |
|
| 13 |
PREREQUISITES |
| 14 |
|
| 15 |
Tested versions: |
| 16 |
zziplib 0.10.66 (preview), SDL 1.2.5, Win32, MSVC6 |
| 17 |
|
| 18 |
Homepages (download) |
| 19 |
zziplib.sourceforge.net (zziplib-0.10.66.tar.gz) |
| 20 |
www.libsdl.org (SDL-devel-1.2.5a-VC6.zip) |
| 21 |
|
| 22 |
Also you have to get zlib, I used |
| 23 |
from SDL_image-1.2.2.zip in VisualC.zip: |
| 24 |
zlib.lib (12.7.1998, 34674 bytes) |
| 25 |
zlib.h ( 9.7.1998, 41791 bytes, 1.1.3) |
| 26 |
zconf.h ( 8.7.1998, 8089 bytes) |
| 27 |
|
| 28 |
from SDL_image-devel-1.2.2-VC6.zip: |
| 29 |
zlib.dll ( 5.4.2001, 53760 bytes, 1.1.3.1) |
| 30 |
|
| 31 |
Maybe you should get the latest version (currently 1.1.4) from |
| 32 |
http://gnuwin32.sourceforge.net/install.html |
| 33 |
(see notes at end of page!) |
| 34 |
|
| 35 |
|
| 36 |
CREATING zzlib.dll/zzlib.lib |
| 37 |
|
| 38 |
Copy your versions of zlib.lib, zlib.h and zconf.h to the zzlib |
| 39 |
directory. |
| 40 |
In MSVC (start zziplib.dsw) |
| 41 |
Add zlib.lib to the files for the zziplib_DLL project. |
| 42 |
Add ZLIB_DLL to the preprocessor definitions. |
| 43 |
|
| 44 |
Set the active project and the active configuration to create zziplib.dll |
| 45 |
and zziplib.lib (I created and used the release version). |
| 46 |
|
| 47 |
|
| 48 |
USING zzlib WITH SDL |
| 49 |
|
| 50 |
Include/add the following files to your SDL-Project |
| 51 |
(put them in proper directories, etc.): |
| 52 |
|
| 53 |
Header files: |
| 54 |
zconf.h |
| 55 |
zlib.h |
| 56 |
zzip.h |
| 57 |
zzip-conf.h |
| 58 |
zzip-io.h |
| 59 |
zziplib.h |
| 60 |
zzip-msvc.h |
| 61 |
zzip-stdint.h |
| 62 |
|
| 63 |
Libraries: |
| 64 |
zlib.lib |
| 65 |
zziplib.lib |
| 66 |
|
| 67 |
DLLs: |
| 68 |
zlib.dll |
| 69 |
zziplib.dll |
| 70 |
|
| 71 |
you may also want to use |
| 72 |
SDL_rwops_zzip.c |
| 73 |
SDL_rwops_zzip.h |
| 74 |
|
| 75 |
|
| 76 |
For compiling it should be sufficient to use |
| 77 |
#include <zziplib.h> |
| 78 |
in the files where you use zziplib-functions. |
| 79 |
|
| 80 |
|
| 81 |
NOTE |
| 82 |
|
| 83 |
It is possible to use both original (unzipped) and zipped versions of files, |
| 84 |
and zziplib will take one of them (depending on the modes when calling |
| 85 |
zziplib). |
| 86 |
|
| 87 |
But this didn't work for all of my original files, so I suggest using zipped |
| 88 |
files only (and remove the original unzipped files, so zziplib doesn't try to |
| 89 |
open the original version). |
| 90 |
|
| 91 |
|
| 92 |
HINT |
| 93 |
|
| 94 |
When opening many files from a zip, its faster to open the zip-directory |
| 95 |
only once, and not for every file access. You may want to modify |
| 96 |
SDL_rwops_zzip for this to get code like: |
| 97 |
|
| 98 |
|
| 99 |
SDL_Surface* image; |
| 100 |
SDL_RWops* rw; |
| 101 |
SDL_Surface* temp1 = NULL; //default > NULL > error |
| 102 |
SDL_Surface* temp2 = NULL; //default > NULL > error |
| 103 |
|
| 104 |
//last param may be used for err return |
| 105 |
ZZIP_DIR* zzipdir = zzip_dir_open( "figures.zip", NULL ); |
| 106 |
|
| 107 |
ZZIP_FILE* zfile = zzip_file_open(zzipdir, "f1.bmp", ZZIP_CASELESS); |
| 108 |
|
| 109 |
if (zfile) |
| 110 |
{ |
| 111 |
rw = SDL_RWFromZZIP(zfile); //modified version |
| 112 |
if (rw) |
| 113 |
{ |
| 114 |
temp1 = IMG_Load_RW(rw, 0); |
| 115 |
SDL_FreeRW(rw); |
| 116 |
} |
| 117 |
int zret = zzip_file_close( zfile ); |
| 118 |
} |
| 119 |
|
| 120 |
zfile = zzip_file_open(zzipdir, "f2.bmp", ZZIP_CASELESS); |
| 121 |
if (zfile) |
| 122 |
{ |
| 123 |
rw = SDL_RWFromZZIP(zfile); //modified version |
| 124 |
if (rw) |
| 125 |
{ |
| 126 |
temp2 = IMG_Load_RW(rw, 0); |
| 127 |
SDL_FreeRW(rw); |
| 128 |
} |
| 129 |
int zret = zzip_file_close( zfile ); |
| 130 |
} |
| 131 |
|
| 132 |
//.. etc |
| 133 |
|
| 134 |
zzip_dir_close( zzipdir ); |