crystalspace.jbind.interfaces.ivideo.graph2d
Interface iGraphics2D

All Superinterfaces:
iBase, iPointer
All Known Implementing Classes:
csGraphics2D

public interface iGraphics2D
extends iBase

This is the interface for 2D renderer. The 2D renderer is responsible for all 2D operations such as creating the window, switching pages, returning pixel format and so on.

Author:
Java wrapper - Quentin Anciaux, c++ version - http://crystal.sourceforge.net/docs/online/devapi/structiGraphics2D.php

Method Summary
 void allowResize(boolean iAllow)
          Enable/disable canvas resizing.
 boolean beginDraw()
          This routine should be called before any draw operations.
 void blit(int x, int y, int width, int height, byte[] data)
          Blit a memory block.
 void clear(int color)
          Clear backbuffer.
 void clearAll(int color)
          Clear all video pages.
 boolean clipLine(float x1, float y1, float x2, float y2, int xmin, int ymin, int xmax, int ymax)
          Clip a line against given rectangle.
 void close()
          Close the device.
 iGraphics2D createOffscreenCanvas(iPointer memory, int width, int height, int depth, iOffscreenCanvasCallback ofscb)
          Create an off-screen canvas so you can render on a given memory area.
 boolean doubleBuffer(boolean Enable)
          Enable or disable double buffering; returns success status.
 void drawBox(int x, int y, int w, int h, int color)
          Draw a box.
 void drawLine(float x1, float y1, float x2, float y2, int color)
          Draw a line.
 void drawPixel(int x, int y, int color)
          Draw a pixel.
 void drawPixels(csPixelCoord pixels, int num_pixels, int color)
          Draw an array of pixel coordinates with the given color.
 int findRGB(int r, int g, int b)
          Find an RGB color.
 void finishDraw()
          This routine should be called when you finished drawing.
 void freeArea(csImageArea Area)
          Free storage allocated for a subarea of screen.
 int[] getClipRect()
          Retrieve clipping rectangle.
 boolean getDoubleBufferState()
          Get the double buffer state.
 iFontServer getFontServer()
          Get the active font server (does not do IncRef(););.
 boolean getFullScreen()
          Returns 'true' if the program is being run full-screen.
 float getGamma()
          Get gamma value.
 int getHeight()
          Return the height of the framebuffer.
 iNativeWindow getNativeWindow()
          Get the native window corresponding with this canvas.
 int getPage()
          Get active videopage number (starting from zero);.
 int getPalEntryCount()
          Return the number of palette entries that can be modified.
 csRGBpixel getPalette()
          Get the palette (if there is one);.
 byte[] getPixel(int x, int y)
          Query pixel R,G,B at given screen location.
 iPointer getPixelAt(int x, int y)
          Returns the address of the pixel at the specified (x, y); coordinates.
 int getPixelBytes()
          Return the number of bytes for every pixel.
 csPixelFormat getPixelFormat()
          Return information about the pixel format.
 int getWidth()
          Return the width of the framebuffer.
 boolean open()
          Open the device.
 void print(csRect pArea)
          Flip video pages (or dump backbuffer into framebuffer);.
 boolean resize(int w, int h)
          Resize the canvas.
 void restoreArea(csImageArea Area, boolean Free)
          Restore a subarea of screen saved with SaveArea();.
 csImageArea saveArea(int x, int y, int w, int h)
          Save a subarea of screen and return a handle to saved buffer.
 iImage screenShot()
          Do a screenshot: return a new iImage object.
 void setClipRect(int nMinX, int nMinY, int nMaxX, int nMaxY)
          Set clipping rectangle.
 void setFullScreen(boolean b)
          Change the fullscreen state of the canvas.
 boolean setGamma(float gamma)
          Set gamma value (if supported by canvas);.
 boolean setMouseCursor(iImage image, csRGBcolor keycolor)
          Set mouse cursor using an image.
 boolean setMouseCursor(iImage image, csRGBcolor keycolor, int hotspot_x)
          Set mouse cursor using an image.
 boolean setMouseCursor(iImage image, csRGBcolor keycolor, int hotspot_x, int hotspot_y)
          Set mouse cursor using an image.
 boolean setMouseCursor(iImage image, csRGBcolor keycolor, int hotspot_x, int hotspot_y, csRGBcolor fg)
          Set mouse cursor using an image.
 boolean setMouseCursor(iImage image, csRGBcolor keycolor, int hotspot_x, int hotspot_y, csRGBcolor fg, csRGBcolor bg)
          Set mouse cursor using an image.
 boolean setMouseCursor(int iShape)
          Set mouse cursor to one of predefined shape classes (see csmcXXX enum above);.
 boolean setMousePosition(int x, int y)
          Set mouse position (relative to top-left of CS window);.
 void setRGB(int i, int r, int g, int b)
          Set a color index to given R,G,B (0..255); values.
 void write(iFont font, int x, int y, int fg, int bg, java.lang.String str)
          Write a text string into the back buffer.
 void write(iFont font, int x, int y, int fg, int bg, java.lang.String str, int flags)
          Write a text string into the back buffer.
 void writeBaseline(iFont font, int x, int y, int fg, int bg, java.lang.String str)
          Deprecated. Instead, use Write(); with the CS_WRITE_BASELINE flag set. Implemented in csGraphics2D, and csGraphics2DNull.
 
Methods inherited from interface crystalspace.jbind.interfaces.iutil.scf.iBase
decRef, getName, getRefCount, getVersion, incRef, queryInterface, queryInterfaceSafe
 
Methods inherited from interface crystalspace.jbind.interfaces.iPointer
changePointer, getPointer, isMemoryOwner, setMemoryOwner
 

Method Detail

allowResize

public void allowResize(boolean iAllow)
Enable/disable canvas resizing. Implemented in csGraphics2D, csGraphics2DOpenGL, csGraphics2DGLX, and csGraphics2DXLib.

Parameters:
iAllow -

beginDraw

public boolean beginDraw()
This routine should be called before any draw operations. It should return true if graphics context is ready. Implemented in csGraphics2DAA, csGraphics2D, csGraphics2DDDraw3, csGraphicsMemory, csGraphics2DNull, csGraphics2DGLCommon, csGraphics2DSDL, and csGraphics2DSVGALib.

Returns:

blit

public void blit(int x,
                 int y,
                 int width,
                 int height,
                 byte[] data)
Blit a memory block. The format of the image is RGBA in bytes. Row by row. Implemented in csGraphics2D, csGraphics2DNull, and csGraphics2DGLCommon.

Parameters:
x -
y -
width -
height -
data -

clear

public void clear(int color)
Clear backbuffer. Implemented in csGraphics2D, csGraphics2DNull, and csGraphics2DGLCommon.

Parameters:
color -

clearAll

public void clearAll(int color)
Clear all video pages. Implemented in csGraphics2D, and csGraphics2DNull.

Parameters:
color -

clipLine

public boolean clipLine(float x1,
                        float y1,
                        float x2,
                        float y2,
                        int xmin,
                        int ymin,
                        int xmax,
                        int ymax)
Clip a line against given rectangle. Function returns true if line is not visible. Implemented in csGraphics2D.

Parameters:
x1 -
y1 -
x2 -
y2 -
xmin -
ymin -
xmax -
ymax -
Returns:

close

public void close()
Close the device. Implemented in csGraphics2DAA, csGraphics2D, csGraphics2DDDraw3, csGraphicsMemory, csGraphics2DNull, csGraphics2DGLCommon, csGraphics2DOpenGL, csGraphics2DGLX, csGraphics2DSDL, csGraphics2DXLib, and csGraphics2DSVGALib.


createOffscreenCanvas

public iGraphics2D createOffscreenCanvas(iPointer memory,
                                         int width,
                                         int height,
                                         int depth,
                                         iOffscreenCanvasCallback ofscb)
Create an off-screen canvas so you can render on a given memory area. If depth==8 then the canvas will use palette mode. In that case you can do SetRGB(); to initialize the palette. The callback interface (if given); is used to communicate from the canvas back to the caller. You can use this to detect when the texture data has changed for example. Implemented in csGraphics2D.

Parameters:
memory -
width -
height -
depth -
ofscb -
Returns:

doubleBuffer

public boolean doubleBuffer(boolean Enable)
Enable or disable double buffering; returns success status. Implemented in csGraphics2D, csGraphics2DDDraw3, csGraphicsMemory, csGraphics2DGLCommon, and csGraphics2DSVGALib.

Parameters:
Enable -
Returns:

drawBox

public void drawBox(int x,
                    int y,
                    int w,
                    int h,
                    int color)
Draw a box. Implemented in csGraphics2D, csGraphics2DNull, and csGraphics2DGLCommon.

Parameters:
x -
y -
w -
h -
color -

drawLine

public void drawLine(float x1,
                     float y1,
                     float x2,
                     float y2,
                     int color)
Draw a line. Implemented in csGraphics2D, csGraphics2DNull, and csGraphics2DGLCommon.

Parameters:
x1 -
y1 -
x2 -
y2 -
color -

drawPixel

public void drawPixel(int x,
                      int y,
                      int color)
Draw a pixel. Implemented in csGraphics2D, csGraphics2DNull, and csGraphics2DGLCommon.

Parameters:
x -
y -
color -

drawPixels

public void drawPixels(csPixelCoord pixels,
                       int num_pixels,
                       int color)
Draw an array of pixel coordinates with the given color. Implemented in csGraphics2D, csGraphics2DNull, and csGraphics2DGLCommon.

Parameters:
pixels -
num_pixels -
color -

findRGB

public int findRGB(int r,
                   int g,
                   int b)
Find an RGB color. Implemented in csGraphics2D.

Parameters:
r -
g -
b -
Returns:

finishDraw

public void finishDraw()
This routine should be called when you finished drawing. Implemented in csGraphics2DAA, csGraphics2D, csGraphics2DDDraw3, csGraphicsMemory, csGraphics2DNull, and csGraphics2DSDL.


freeArea

public void freeArea(csImageArea Area)
Free storage allocated for a subarea of screen. Implemented in csGraphics2D.

Parameters:
Area -

getClipRect

public int[] getClipRect()
Retrieve clipping rectangle. Implemented in csGraphics2D.

Returns:

getDoubleBufferState

public boolean getDoubleBufferState()
Get the double buffer state. Implemented in csGraphics2D, csGraphics2DDDraw3, csGraphics2DGLCommon, and csGraphics2DSVGALib.

Returns:

getFontServer

public iFontServer getFontServer()
Get the active font server (does not do IncRef(););. Implemented in csGraphics2D.

Returns:

getFullScreen

public boolean getFullScreen()
Returns 'true' if the program is being run full-screen. Implemented in csGraphics2D, csGraphics2DGLX, and csGraphics2DXLib.

Returns:

getGamma

public float getGamma()
Get gamma value. Implemented in csGraphics2D.

Returns:

getHeight

public int getHeight()
Return the height of the framebuffer. Implemented in csGraphics2D.

Returns:

getNativeWindow

public iNativeWindow getNativeWindow()
Get the native window corresponding with this canvas. If this is an off-screen canvas then this will return 0. Implemented in csGraphics2D.

Returns:

getPage

public int getPage()
Get active videopage number (starting from zero);. Implemented in csGraphics2D, and csGraphics2DDDraw3.

Returns:

getPalEntryCount

public int getPalEntryCount()
Return the number of palette entries that can be modified. This should return 0 if there is no palette (true color displays);. This function is equivalent to the PalEntries field that you get from GetPixelFormat. It is just a little bit easier to obtain this way. Implemented in csGraphics2D.

Returns:

getPalette

public csRGBpixel getPalette()
Get the palette (if there is one);. Implemented in csGraphics2D.

Returns:

getPixel

public byte[] getPixel(int x,
                       int y)
Query pixel R,G,B at given screen location. Implemented in csGraphics2D.

Parameters:
x -
y -
Returns:

getPixelAt

public iPointer getPixelAt(int x,
                           int y)
Returns the address of the pixel at the specified (x, y); coordinates. Implemented in csGraphics2D, csGraphics2DNull, and csGraphics2DGLCommon.

Parameters:
x -
y -
Returns:

getPixelBytes

public int getPixelBytes()
Return the number of bytes for every pixel. This function is equivalent to the PixelBytes field that you get from GetPixelFormat. Implemented in csGraphics2D.

Returns:

getPixelFormat

public csPixelFormat getPixelFormat()
Return information about the pixel format. Implemented in csGraphics2D.

Returns:

getWidth

public int getWidth()
Return the width of the framebuffer. Implemented in csGraphics2D.

Returns:

open

public boolean open()
Open the device. Implemented in csGraphics2DAA, csGraphics2D, csGraphics2DDDraw3, csGraphicsMemory, csGraphics2DNull, csGraphics2DGLCommon, csGraphics2DOpenGL, csGraphics2DGLX, csGraphics2DSDL, csGraphics2DXLib, and csGraphics2DSVGALib.

Returns:

print

public void print(csRect pArea)
Flip video pages (or dump backbuffer into framebuffer);. The area parameter is only a hint to the canvas driver. Changes outside the rectangle may or may not be printed as well. Implemented in csGraphics2DAA, csGraphics2D, csGraphics2DDDraw3, csGraphicsMemory, csGraphics2DNull, csGraphics2DOpenGL, csGraphics2DGLX, csGraphics2DSDL, csGraphics2DXLib, and csGraphics2DSVGALib.

Parameters:
pArea -

resize

public boolean resize(int w,
                      int h)
Resize the canvas. Implemented in csGraphics2D, csGraphics2DGLCommon, and csGraphics2DXLib.

Parameters:
w -
h -
Returns:

restoreArea

public void restoreArea(csImageArea Area,
                        boolean Free)
Restore a subarea of screen saved with SaveArea();. Implemented in csGraphics2D, and csGraphics2DGLCommon.

Parameters:
Area -
Free -

saveArea

public csImageArea saveArea(int x,
                            int y,
                            int w,
                            int h)
Save a subarea of screen and return a handle to saved buffer. Storage is allocated in this call, you should either FreeArea(); the handle after usage or RestoreArea (); it. Implemented in csGraphics2D, and csGraphics2DGLCommon.

Parameters:
x -
y -
w -
h -
Returns:

screenShot

public iImage screenShot()
Do a screenshot: return a new iImage object. Implemented in csGraphics2D, and csGraphics2DGLCommon.

Returns:

setClipRect

public void setClipRect(int nMinX,
                        int nMinY,
                        int nMaxX,
                        int nMaxY)
Set clipping rectangle. The clipping rectangle is inclusive the top and left edges and exclusive for the right and bottom borders. Implemented in csGraphics2D.

Parameters:
nMinX -
nMinY -
nMaxX -
nMaxY -

setFullScreen

public void setFullScreen(boolean b)
Change the fullscreen state of the canvas. Implemented in csGraphics2D, csGraphics2DGLX, and csGraphics2DXLib.

Parameters:
b -

setGamma

public boolean setGamma(float gamma)
Set gamma value (if supported by canvas);. By default this is 1. Smaller values are darker. If the canvas doesn't support gamma then this function will return false. Implemented in csGraphics2D.

Parameters:
gamma -
Returns:

setMouseCursor

public boolean setMouseCursor(iImage image,
                              csRGBcolor keycolor)
Set mouse cursor using an image. If the operation is unsupported, return 'false' otherwise return 'true'. On some platforms there is only monochrome pointers available. In this all black colors in the image will become the value of 'bg' and all non-black colors will become 'fg' Implemented in csGraphics2D, and csGraphics2DXLib.

Parameters:
image -
keycolor -
Returns:

setMouseCursor

public boolean setMouseCursor(iImage image,
                              csRGBcolor keycolor,
                              int hotspot_x)
Set mouse cursor using an image. If the operation is unsupported, return 'false' otherwise return 'true'. On some platforms there is only monochrome pointers available. In this all black colors in the image will become the value of 'bg' and all non-black colors will become 'fg' Implemented in csGraphics2D, and csGraphics2DXLib.

Parameters:
image -
keycolor -
hotspot_x -
Returns:

setMouseCursor

public boolean setMouseCursor(iImage image,
                              csRGBcolor keycolor,
                              int hotspot_x,
                              int hotspot_y)
Set mouse cursor using an image. If the operation is unsupported, return 'false' otherwise return 'true'. On some platforms there is only monochrome pointers available. In this all black colors in the image will become the value of 'bg' and all non-black colors will become 'fg' Implemented in csGraphics2D, and csGraphics2DXLib.

Parameters:
image -
keycolor -
hotspot_x -
hotspot_y -
Returns:

setMouseCursor

public boolean setMouseCursor(iImage image,
                              csRGBcolor keycolor,
                              int hotspot_x,
                              int hotspot_y,
                              csRGBcolor fg)
Set mouse cursor using an image. If the operation is unsupported, return 'false' otherwise return 'true'. On some platforms there is only monochrome pointers available. In this all black colors in the image will become the value of 'bg' and all non-black colors will become 'fg' Implemented in csGraphics2D, and csGraphics2DXLib.

Parameters:
image -
keycolor -
hotspot_x -
hotspot_y -
fg -
Returns:

setMouseCursor

public boolean setMouseCursor(iImage image,
                              csRGBcolor keycolor,
                              int hotspot_x,
                              int hotspot_y,
                              csRGBcolor fg,
                              csRGBcolor bg)
Set mouse cursor using an image. If the operation is unsupported, return 'false' otherwise return 'true'. On some platforms there is only monochrome pointers available. In this all black colors in the image will become the value of 'bg' and all non-black colors will become 'fg' Implemented in csGraphics2D, and csGraphics2DXLib.

Parameters:
image -
keycolor -
hotspot_x -
hotspot_y -
fg -
bg -
Returns:

setMouseCursor

public boolean setMouseCursor(int iShape)
Set mouse cursor to one of predefined shape classes (see csmcXXX enum above);. If a specific mouse cursor shape is not supported, return 'false'; otherwise return 'true'. If system supports it the cursor should be set to its nearest system equivalent depending on iShape argument and the routine should return "true". Implemented in csGraphics2DAA, csGraphics2D, csGraphics2DDDraw3, csGraphics2DNull, csGraphics2DOpenGL, csGraphics2DGLX, csGraphics2DSDL, and csGraphics2DXLib.

Parameters:
iShape -
Returns:

setMousePosition

public boolean setMousePosition(int x,
                                int y)
Set mouse position (relative to top-left of CS window);. Implemented in csGraphics2DAA, csGraphics2D, csGraphics2DDDraw3, csGraphics2DNull, csGraphics2DOpenGL, csGraphics2DGLX, csGraphics2DSDL, and csGraphics2DXLib.

Parameters:
x -
y -
Returns:

setRGB

public void setRGB(int i,
                   int r,
                   int g,
                   int b)
Set a color index to given R,G,B (0..255); values. Implemented in csGraphics2DAA, csGraphics2D, csGraphics2DDDraw3, csGraphics2DNull, csGraphics2DGLCommon, csGraphics2DOpenGL, csGraphics2DSDL, csGraphics2DXLib, and csGraphics2DSVGALib.

Parameters:
i -
r -
g -
b -

write

public void write(iFont font,
                  int x,
                  int y,
                  int fg,
                  int bg,
                  java.lang.String str)
Write a text string into the back buffer. A negative value for bg color will not draw the background. Implemented in csGraphics2D.

Parameters:
font -
x -
y -
fg -
bg -
str -

write

public void write(iFont font,
                  int x,
                  int y,
                  int fg,
                  int bg,
                  java.lang.String str,
                  int flags)
Write a text string into the back buffer. A negative value for bg color will not draw the background. Implemented in csGraphics2D.

Parameters:
font -
x -
y -
fg -
bg -
str -
flags -

writeBaseline

public void writeBaseline(iFont font,
                          int x,
                          int y,
                          int fg,
                          int bg,
                          java.lang.String str)
Deprecated. Instead, use Write(); with the CS_WRITE_BASELINE flag set. Implemented in csGraphics2D, and csGraphics2DNull.

Write a text string into the back buffer. A negative value for bg color will not draw the background. x and y are the pen position on a baseline. The actual font baseline is shifted up by the font's descent.

Parameters:
font -
x -
y -
fg -
bg -
str -