|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sdl.video.Video
The Video class is used to modify and query the state of the SDL Video subsystem. The first step is to initialize the SDL Video subsytem. then instantiate a new Video() object.
int res = sdl.SDLInit(Main.SDL_INIT_VIDEO); Video video = new Video();The next step is to set the video mode and get a reference to the SDLurface object that represents the framebuffer you will write pixels to.
SDLSurface surface = null; surface = video.setVideoMode(1024,768,16,Video.SDL_FULLSCREEN);Here is the full code snippit
Main sdl = new Main(); SDLSurface surface = null; try { int res = sdl.SDLInit(Main.SDL_INIT_VIDEO); System.out.println("TestVideo SDL Initialization res:" + res); Video video = new Video(); surface = video.setVideoMode(1024,768,16,Video.SDL_FULLSCREEN); } catch (Exception e) { System.out.println("Exception: " + e); }
Most of the interesting state variables for the Video subsystem are held in a reference to the current SDLSurface. Information on current color depth, screen size, etc are stored in this Surface's SDLPixelFormat.
SDLPixelFormat videoFormat =video.getVideoSurface().m_Format;
SDLSurface
,
SDLPixelFormat
Field Summary | |
static int |
SDL_ANYFORMAT
Use a differing color depth if the one requested is unavailable. |
static int |
SDL_ASYNCBLIT
Enable the use of asynchronous updates of the display surface. |
static int |
SDL_DISABLE
Hide the cursor. |
static int |
SDL_DOUBLEBUF
Enable hardware double buffering; only valid with SDL_HWSURFACE. |
static int |
SDL_ENABLE
Show the cursor |
static int |
SDL_FULLSCREEN
Use fullscreen mode, if available. |
static int |
SDL_HWACCEL
Blit uses hardware acceleration |
static int |
SDL_HWPALETTE
Give SDL exclusive palette access. |
static int |
SDL_HWSURFACE
Put the surface in video memory, if possible. |
static int |
SDL_OPENGL
Create an OpenGL rendering context. |
static int |
SDL_OPENGLBLIT
Create an OpenGL rendering context, like SDL_OPENGL, but allow normal blitting operations. |
static int |
SDL_PREALLOC
Surface uses preallocated memory |
static int |
SDL_QUERY
Is the cursor visible? |
static int |
SDL_RESIZABLE
If operating in a windowed environment, allow the user to resize the window. |
static int |
SDL_RLEACCEL
Colorkey blit is RLE accelerated |
static int |
SDL_RLEACCELOK
Private flag |
static int |
SDL_SRCALPHA
Blit uses source alpha blending |
static int |
SDL_SRCCOLORKEY
Blit uses a source color key |
static int |
SDL_SWSURFACE
Put the surface in regular memory. |
Constructor Summary | |
Video()
|
Method Summary | |
SDLCursor |
createCursor(byte[] data,
byte[] mask,
int width,
int height,
int hotX,
int hotY)
Create a cursor. |
SDLSurface |
createRGBSurface(int flags,
int width,
int height,
int depth,
int rMask,
int gMask,
int bMask,
int aMask)
Create a new SDLSurface. |
SDLSurface |
createRGBSurfaceFrom(byte[] pixels,
int flags,
int width,
int height,
int depth,
int pitch,
int rMask,
int gMask,
int bMask,
int aMask)
Create a new SDLSurface and fill it with the data. |
protected void |
finalize()
|
void |
freeVideo()
Frees the root SDLSurface created by setVideoMode. |
SDLCursor |
getCursor()
|
boolean |
getGammaRamp(short[] redTable,
short[] greenTable,
short[] blueTable)
TODO: should probably throw a RuntimeException if length!=256 |
java.util.Vector |
getListModes(SDLPixelFormat format,
int flags)
|
void |
getRGB(int pixel,
SDLPixelFormat format,
byte[] color)
TODO: should probably throw a RuntimeException if color.length!=3 |
void |
getRGBA(int pixel,
SDLPixelFormat format,
byte[] color)
TODO: should probably throw a RuntimeException if color.length!=4 |
java.lang.String |
getVideoDriverName()
Get the name of the driver used by the screen SDLSurface. |
SDLVideoInfo |
getVideoInfo()
Get video info about the screen SDLSurface. |
SDLSurface |
getVideoSurface()
Get the screen SDLSurface. |
int |
isVideoModeOk(int width,
int height,
int bpp,
int flags)
TODO: could this be made boolean? |
boolean |
setGammaRamp(short[] redTable,
short[] greenTable,
short[] blueTable)
TODO: should probably throw a RuntimeException if length!=256 |
SDLSurface |
setVideoMode(int width,
int height,
int bpp,
int flags)
Sets the video mode. |
int |
showCursor(int toggle)
Hide, show, or return the state of the cursor. |
void |
warpMouse(short x,
short y)
Warp the mouse to a specific point on the screen. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SDL_SWSURFACE
public static final int SDL_HWSURFACE
public static final int SDL_OPENGL
sdl.video.gl#setAttributes()
,
Constant Field Valuespublic static final int SDL_ASYNCBLIT
public static final int SDL_OPENGLBLIT
SDL_OPENGL
,
Constant Field Valuespublic static final int SDL_RESIZABLE
setVideoMode(int, int, int, int)
,
Constant Field Valuespublic static final int SDL_ANYFORMAT
public static final int SDL_HWPALETTE
TODO:
,
#setPalette()
,
Constant Field Valuespublic static final int SDL_DOUBLEBUF
SDLSurface.flip()
,
Constant Field Valuespublic static final int SDL_FULLSCREEN
public static final int SDL_HWACCEL
public static final int SDL_SRCCOLORKEY
public static final int SDL_RLEACCELOK
public static final int SDL_RLEACCEL
public static final int SDL_SRCALPHA
public static final int SDL_PREALLOC
public static final int SDL_QUERY
showCursor(int)
,
Constant Field Valuespublic static final int SDL_DISABLE
showCursor(int)
,
Constant Field Valuespublic static final int SDL_ENABLE
showCursor(int)
,
Constant Field ValuesConstructor Detail |
public Video()
Method Detail |
public SDLSurface setVideoMode(int width, int height, int bpp, int flags)
width
- desired screen widthheight
- desired screen heightbpp
- specifies the bits per pixel, commonly 8, 15, 16, 24, or 32flags
- should be one of SDL_SWSURFACE or SDL_HWSURFACE, optionally ORed with any of
SDL_OPENGL, SDL_ASYNCBLIT, SDL_OPENGLBLIT, SDL_RESIZABLE, SDL_ANYFORMAT,
SDL_HWPALETTE, SDL_DOUBLEBUF, and SDL_FULLSCREEN.
SDL_SWSURFACE
,
SDL_HWSURFACE
,
SDL_OPENGL
,
SDL_ASYNCBLIT
,
SDL_OPENGLBLIT
,
SDL_RESIZABLE
,
SDL_ANYFORMAT
,
SDL_HWPALETTE
,
SDL_DOUBLEBUF
,
SDL_FULLSCREEN
public void freeVideo()
setVideoMode(int, int, int, int)
public SDLSurface getVideoSurface()
public SDLVideoInfo getVideoInfo()
public java.lang.String getVideoDriverName()
public java.util.Vector getListModes(SDLPixelFormat format, int flags)
public int isVideoModeOk(int width, int height, int bpp, int flags)
public boolean getGammaRamp(short[] redTable, short[] greenTable, short[] blueTable)
public boolean setGammaRamp(short[] redTable, short[] greenTable, short[] blueTable)
public void getRGB(int pixel, SDLPixelFormat format, byte[] color)
color
- must be 3 bytes long!public void getRGBA(int pixel, SDLPixelFormat format, byte[] color)
color
- must be 4 bytes long!public SDLSurface createRGBSurface(int flags, int width, int height, int depth, int rMask, int gMask, int bMask, int aMask)
public SDLSurface createRGBSurfaceFrom(byte[] pixels, int flags, int width, int height, int depth, int pitch, int rMask, int gMask, int bMask, int aMask)
pixels
- the data to fill the SDLSurface withpublic void warpMouse(short x, short y)
public SDLCursor createCursor(byte[] data, byte[] mask, int width, int height, int hotX, int hotY)
public SDLCursor getCursor()
public int showCursor(int toggle)
toggle
- one of SDL_ENABLE, SDL_DISABLE, or SDL_QUERY.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |