|
|||||||||||
PREV NEXT | FRAMES NO FRAMES |
See:
Description
Packages | |
sdl.audio | Java bindings for SDL audio subsystem. |
sdl.cdrom | Java binding for SDLCD library, plays an audio CD in SDL |
sdl.core | JSDL runtime interfaces. |
sdl.event | |
sdl.ext.sdlimage | Java binding for SDL_Image library (loads BMP, PNM, XPM, LBM, PCX, GIF, JPEG, PNG, TGA) |
sdl.ext.sfont | Java bindings for SFont SDL font library. |
sdl.mpeg | Java binding for SMPEG library - Mpeg I/ MP3 decoder and player. |
sdl.utils | |
sdl.video | Java binding for SDL video subsystem |
sdl.window |
Description: Java for SDL is a binding for SDL written in java.
Using JSDL
Java for SDL
Javadoc and Code Samples
Developing in JSDL
API Overview
Java for SDL is a binding for SDL written in Java. Now you can use SDL and still program with Java.About SDL ( copied from SDL toc)
For more information, refer to the JSDL project homepage at http://jsdl.sourceforge.net
JSDL Core FeaturesFor more information, refer to the SDL project homepage at http://www.libsdl.org/.
- Simple DirectMedia Layer is a free cross-platform multi-media development API
- Used for games
- Used for game SDKs
- Used for emulators
- Used for demos
- Used for multimedia applications
libSDL4Java.so must be added to the java.library.path. The easiest way to do this is to run java with the following arguments.
java -Djava.library.path=$JSDL_BASE
where $JSDL_BASE is the directory containing this library.
jsdl.jar must be added to the classpath when compiling and testing your JSDL application.
JSDL_BASE=/home/sstraw/build/jsdlPorting/Rebuilding JSDL
cd sdl/test
javac -classpath .:$JSDL_BASE TestVideo.java
cd ../..
java -Djava.library.path=$JSDL_BASE:/usr/lib -classpath .:$JSDL_BASE/build sdl.test.TestVideo.java
Main sdl = new Main();Next, we need to initialize the video buffer through the java.video.Video class, and retreive a reference to the "SDLSurface" object. The "surface" object is our interface to the framebuffer itself. (We will discuss surfaces later)
int result = sdl.SDLInit(Main.SDL_INIT_VIDEO);
Video video = new Video();When are finished with our SDL routines, we (should) free whatever resources we've consumed, unlock the framebufffer, etc. This is done through the following method in the "Main" object.
SDLSurface surface = video.setVideoMode(640,480,16);
sdl.SDLQuit()Surfaces
SDLSurface surface = video.setVideoMode(640,480,16);or may refer to an offscreen image buffer.
SDLSurface image = SDLImage.createFromFile("/tmp/icon23.jpg");Since surfaces in JSDL have built in buffering, it is necessary to "update" the surface so the changes are pushed to the actual graphics device.
surface.updateRawPixels();Pixels and PixelFormat
surface.updateRect(0,0,0,0);
public static short createHiColor(SDLPixelFormat fmt, byte red, byte green, byte blue)An alternative convenience routine creates a pixel value based on the color depth of an arbitrary surface.
{
short value = (short) (((red >> fmt.m_RLoss) << fmt.m_RShift) + ((green >> fmt.m_GLoss) << fmt.m_GShift) + ((blue >> fmt.m_BLoss) << fmt.m_BShift));
return value;
}
int colorkey = surface.mapRGB((byte)0,(byte)0,(byte)0) ;Events
Classes that will listen to JSDL events must implement the sdl.event.SDLEventListener interface and create this single method,
- SDLKeyboardEvent
- SDLMouseButtonEvent
- SDLMouseMotionEvent
- SDLQuitEvent
- SDLCustomEvent
- SDLUserEvent
public boolean incomingEvents(SDLCustomEvent event) throws SDLEventException;
|
|||||||||||
PREV NEXT | FRAMES NO FRAMES |