.

Architecture


Design

sdljava consists of a set of java API which call into a native "C" layer which in turn call the actual SDL methods. The "C" layer is generated using SWIG. For each SDL header file a SWIG .i (interface file) was created which describes what methods should be mapped and how. SWIG is then run on these interface files to generate the actual C code required to provide the mapping. After SWIG has been run a full set of API exist to call into the SDL routines from java!

One additional layer exists on top of this. The java API generated by SWIG closely matches what swig finds in the header files it is mapping from SDL. This produces something which certainly works, however, it is not quite pleasant to work with the raw types. Therefore sdljava wraps over the SWIG generated java source files. This allows many things to happen which make it easier for the end user to use the library.

It might be easier to understand with a simple illustration:

Lets assume you call setVideoMode() on SDLVideo

SDLVideo.setVideoMode(...)
       |(java, hand-coded)
       |
       |
       -------- SWIG_SDLVideo.SDL_SetVideoMode(...)
                            |(java, SWIG generated)
                            |
                            |
                            -------- SDLVideo_wrap SetVideoMode(...)
                                            |(C, SWIG generated)
                                            |
                                            |
                                            -------- SDL_Video SDL_SetVideoMode(...)
                                                              (C, SDL API)

Lets assume you invoke the method SDLVideo.setVideoMode(). Whats really happening is that the SDLVideo class is delegating the call to the SWIG generated SDL_SDLVideo class.

I hope this very brief overview gives an idea of how some of sdljava works.