Debian Codegraph @

libs/zziplib/zziplib-src/docs/zzip-sdl-rwops.htm

raw symbols SCIP
1 <section> <date> 19. Aug 2001 </date>
2 <h2> SDL rwops </h2> Example to make an SDL_rwops interface.
3
4 <p><small> some <b>MSVC</b> help in
5 <a href="README.MSVC6">README.MSVC6</a> and
6 <a href="README.SDL">README.SDL</a>
7 </small></p>
8
9 <!--border-->
10
11 <section>
12 <h3> Source </h3>
13
14 <P>
15 The example sources of the <a href="zziplib.html">zziplib library</a>
16 are usually put under the <a href="COPYING.ZLIB">ZLIB license</a> so
17 that you can reuse the code freely in your own projects. Here we talk
18 about the example that might be most useful for
19 <a href="http://libsdl.org">SDL</a> based programs.
20 Just copy the two files
21 <a href="SDL_rwops_zzip.h">SDL_rwops_zzip.h</a>
22 and
23 <a href="SDL_rwops_zzip.c">SDL_rwops_zzip.c</a>
24 to the directory with your other project sources, and make sure
25 to link it somehow to your programs. I did not make the effort to
26 create a separate library out of it - it would just export one
27 single function <tt>SDL_RWFromZZIP</tt> that has the same call-synopsis
28 like <tt>SDL_RWFromFile</tt> (but it can not (yet) write a zip-file).
29 </P>
30
31 <P>
32 The source file <a href="SDL_rwops_zzip.c">SDL_rwops_zzip.c</a> is
33 quite short - it just stores a ZZIP_FILE handle in the userdata
34 field of the <tt>SDL_rwops</tt> structure. The SDL'rwop calls will then
35 fetch that pointer and call the corresponding functions from the
36 <a href="zziplib.html">zziplib library</a>. Most of the glue code
37 is in the <tt>SDL_RWFromZZIP</tt> function that allocates an
38 <tt>SDL_rwops</tt> structure and fills the handler-functions
39 into the callback fields.
40 </P>
41
42 </section><section>
43 <h3> Usage </h3>
44
45 <P>
46 If you link this file to your project, remember that your executables
47 do now have additional dependencies - not only -lzzip to link with
48 the <a href="zziplib.html">zziplib library</a> - do not forget to
49 link with zlib library via -lz. Of course, there is a lib-config
50 script that you can use: `zzip-config --libs` will return these
51 linker-infos (unless you have a native-windows system - it is
52 shell-script).
53 </P>
54
55 <P>
56 As an example, replace that <tt>SDL_RWFromFile</tt> that accesses your
57 game-graphic files - these files are stored in shared/myapp
58 of course where they belong. When you've done that
59 then go to X/share/myapp and
60 <br><code>&nbsp;&nbsp;&nbsp;
61 `(cd graphics/ && zip -9r ../graphics.zip .)` </code><br>
62 and rename the graphics/ subfolder - and still all your files
63 are found: a filepath like X/shared/graphics/game/greetings.bmp
64 will open X/shared/graphics.zip and return the zipped file
65 game/greetings.bmp in the zip-archive (for reading that is).
66 </P>
67
68 </section><section>
69 <h3> Test </h3>
70
71 <P>
72 The <a href="zziplib.html">zziplib</a> configure script does not
73 look for <a href="http://libsdl.org">SDL</a>. If you know that
74 you have <a href="http://libsdl.org">SDL</a> installed
75 then you can check this <tt>SDL_rwops</tt> example by using
76 <code><nobr>`make testsdl`</nobr></code>. This will compile the
77 two source files <a href="SDL_rwops_zzip.c">SDL_rwops_zzip.c</a>
78 and <a href="SDL_rwops_zzcat.c">SDL_rwops_zzcat.c</a> to be linked
79 together into an executable called <code>zzcatsdl</code>. The test
80 will continue with a <code><nobr>`zzcatsdl test/README`</nobr></code>
81 - just like it is done for <code><nobr>`make test3`</nobr></code>.
82 </P>
83 <P>
84 The corresponding section in the <a href="Makefile.am">Makefile.am</a>
85 is also an example how to use lib-config scripts to build files. Here
86 there is no build-processing that had been tweaked much by automake/autoconf.
87 Just use sdl-config and zzip-config to add the needed flags.
88 </P>
89 </section></section>
90