csGraphics2D Class Reference
[Common Plugin Classes]
This is the base class for 2D canvases.
More...
#include <csplugincommon/canvas/graph2d.h>
Inherits scfImplementation7<csGraphics2D, iGraphics2D, iComponent, iNativeWindow, iNativeWindowManager, iPluginConfig, iDebugHelper, iEventHandler>.
Inherited by scfImplementationExt2< csGraphics2DGLCommon, csGraphics2D, iEventPlug, iOpenGLDriverDatabase >, and scfImplementationExt2< csGraphics2DGLCommon, csGraphics2D, iEventPlug, iOpenGLDriverDatabase >.
Public Member Functions | |
virtual void | AllowResize (bool) |
Enable/disable canvas resize (Over-ride in sub classes). | |
virtual bool | BeginDraw () |
This routine should be called before any draw operations. | |
virtual void | Blit (int x, int y, int width, int height, unsigned char const *data) |
Blit a memory block. Format of the image is RGBA in bytes. Row by row. | |
virtual void | ChangeDepth (int d) |
Change the depth of the canvas. | |
virtual void | Clear (int color) |
Clear backbuffer. | |
virtual void | ClearAll (int color) |
Clear all video pages. | |
virtual bool | 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. | |
virtual void | Close () |
(*) Close graphics system | |
csGraphics2D (iBase *) | |
Create csGraphics2D object. | |
virtual bool | DoubleBuffer (bool Enable) |
Enable or disable double buffering; return TRUE if supported. | |
virtual void | DrawBox (int x, int y, int w, int h, int color) |
Draw a box of given width and height. | |
virtual void | DrawLine (float x1, float y1, float x2, float y2, int color) |
Draw a line. | |
virtual void | DrawPixel (int x, int y, int color) |
Same but exposed through iGraphics2D interface. | |
virtual void | FinishDraw () |
This routine should be called when you finished drawing. | |
virtual void | FreeArea (csImageArea *Area) |
Free storage allocated for a subarea of screen. | |
virtual void | GetClipRect (int &xmin, int &ymin, int &xmax, int &ymax) |
Query clipping rectangle. | |
virtual bool | GetDoubleBufferState () |
Return current double buffering state. | |
virtual iFontServer * | GetFontServer () |
Gets the font server. | |
virtual bool | GetFullScreen () |
Returns 'true' if the program is being run full-screen. | |
virtual const char * | GetName () const |
Get the name of this canvas. | |
virtual iNativeWindow * | GetNativeWindow () |
Return the Native Window interface for this canvas (if it has one). | |
virtual int | GetPage () |
Get active videopage number (starting from zero). | |
virtual int | GetPalEntryCount () |
Return the number of palette entries that can be modified. | |
virtual csRGBpixel * | GetPalette () |
Get the palette (if there is one). | |
virtual void | GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB, uint8 &oA) |
As GetPixel() above, but with alpha. | |
virtual void | GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB) |
Query pixel R,G,B at given screen location. | |
virtual unsigned char * | GetPixelAt (int x, int y) |
Same but exposed through iGraphics2D interface. | |
virtual int | GetPixelBytes () |
Return the number of bytes for every pixel. | |
virtual csPixelFormat const * | GetPixelFormat () |
Return information about about the pixel format. | |
virtual bool | HandleEvent (iEvent &) |
Event handler for plugin. | |
virtual bool | Initialize (iObjectRegistry *) |
Initialize the plugin. | |
virtual bool | Open () |
(*) Open graphics system (set videomode, open window etc) | |
virtual bool | PerformExtension (char const *command,...) |
Perform a system specific extension. | |
virtual bool | PerformExtensionV (char const *command, va_list) |
Perform a system specific extension. | |
virtual void | Print (csRect const *=0) |
(*) Flip video pages (or dump backbuffer into framebuffer). | |
virtual bool | Resize (int w, int h) |
Resize the canvas. | |
virtual void | RestoreArea (csImageArea *Area, bool Free=true) |
Restore a subarea of screen saved with SaveArea(). | |
virtual csImageArea * | SaveArea (int x, int y, int w, int h) |
Save a subarea of screen area into the variable Data. | |
virtual csPtr< iImage > | ScreenShot () |
Do a screenshot: return a new iImage object. | |
virtual void | SetClipRect (int xmin, int ymin, int xmax, int ymax) |
Set clipping rectangle. | |
virtual void | SetFullScreen (bool b) |
Change the fullscreen state of the canvas. | |
virtual bool | SetMouseCursor (iImage *image, const csRGBcolor *keycolor=0, int hotspot_x=0, int hotspot_y=0, csRGBcolor fg=csRGBcolor(255, 255, 255), csRGBcolor bg=csRGBcolor(0, 0, 0)) |
Set mouse cursor using an image. | |
virtual bool | SetMouseCursor (csMouseCursorID iShape) |
Set mouse cursor to one of predefined shape classes (see csmcXXX enum above). | |
virtual bool | SetMousePosition (int x, int y) |
Set mouse cursor position; return success status. | |
virtual void | SetRGB (int i, int r, int g, int b) |
(*) Set a color index to given R,G,B (0..255) values | |
virtual | ~csGraphics2D () |
Destroy csGraphics2D object. | |
virtual void | Write (iFont *font, int x, int y, int fg, int bg, const wchar_t *text, uint flags=0) |
Write a text string into the back buffer. | |
virtual void | Write (iFont *font, int x, int y, int fg, int bg, const char *text, uint flags=0) |
Write a text string into the back buffer. | |
Public Attributes | |
void(* | _DrawPixel )(csGraphics2D *This, int x, int y, int color) |
To facilitate multiple pixel formats, the most critical drawing routines are defined as pointers to functions, not as virtual methods. | |
unsigned char *(* | _GetPixelAt )(csGraphics2D *This, int x, int y) |
(*) Get address of video RAM at given x,y coordinates | |
bool | AllowResizing |
Whether to allow resizing. | |
int | ClipX1 |
The clipping rectangle. | |
csConfigAccess | config |
The configuration file. | |
int | DisplayNumber |
Display number. | |
int | fbWidth |
The width, height and depth of visual. | |
csFontCache * | fontCache |
The font cache. | |
csWeakRef< iFontServer > | FontServer |
The font server. | |
int | FrameBufferLocked |
The counter that is incremented inside BeginDraw and decremented in FinishDraw(). | |
bool | FullScreen |
True if visual is full-screen. | |
bool | is_open |
Open/Close state. | |
int * | LineAddress |
Keep a array of Y*width to avoid multiplications. | |
unsigned char * | Memory |
Most systems have a pointer to (real or pseudo) video RAM. | |
iObjectRegistry * | object_reg |
The object registry. | |
csRef< iOffscreenCanvasCallback > | ofscb |
Callback to use for informing an external agent when several canvas operations have occured. | |
csRGBpixel * | Palette |
256-color palette. | |
bool | PaletteAlloc [256] |
true if some palette entry is already allocated. | |
csPixelFormat | pfmt |
The pixel format. | |
csWeakRef< iPluginManager > | plugin_mgr |
The plugin manager. | |
csString | win_title |
Pointer to a title. | |
Protected Member Functions | |
iNativeWindowManager implementation | |
virtual void | Alert (int type, const wchar_t *title, const wchar_t *okMsg, const wchar_t *msg,...) |
virtual void | Alert (int type, const char *title, const char *okMsg, const char *msg,...) |
virtual void | AlertV (int type, const wchar_t *title, const wchar_t *okMsg, const wchar_t *msg, va_list args) |
virtual void | AlertV (int type, const char *title, const char *okMsg, const char *msg, va_list args) |
iDebugHelper implementation | |
virtual csTicks | Benchmark (int) |
virtual bool | DebugCommand (const char *cmd) |
virtual void | Dump (iGraphics3D *) |
virtual csPtr< iString > | Dump () |
virtual int | GetSupportedTests () const |
virtual csPtr< iString > | StateTest () |
virtual csPtr< iString > | UnitTest () |
iPluginConfig implementation | |
virtual bool | GetOption (int id, csVariant *value) |
virtual bool | GetOptionDescription (int idx, csOptionDescription *) |
virtual bool | SetOption (int id, csVariant *value) |
iNativeWindow implementation | |
virtual void | SetTitle (const wchar_t *title) |
virtual void | SetTitle (const char *title) |
Static Protected Member Functions | |
static void | DrawPixel16 (csGraphics2D *This, int x, int y, int color) |
Draw a pixel in 16-bit modes. | |
static void | DrawPixel32 (csGraphics2D *This, int x, int y, int color) |
Draw a pixel in 32-bit modes. | |
static void | DrawPixel8 (csGraphics2D *This, int x, int y, int color) |
Default drawing routines for 8-bit and 16-bit modes If a system port has its own routines, it should assign their addresses to respective pointers. | |
static unsigned char * | GetPixelAt16 (csGraphics2D *This, int x, int y) |
Return address of a 16-bit pixel. | |
static unsigned char * | GetPixelAt32 (csGraphics2D *This, int x, int y) |
Return address of a 32-bit pixel. | |
static unsigned char * | GetPixelAt8 (csGraphics2D *This, int x, int y) |
Return address of a 8-bit pixel. | |
Protected Attributes | |
int | refreshRate |
Screen refresh rate. | |
bool | vsync |
Activate Vsync. |
Detailed Description
This is the base class for 2D canvases.Plugins should derive their own class from this one and implement required (marked with an asterisk (*)) functions. Functions not marked with an asterisk are optional, but possibly slow since they are too general.
Definition at line 62 of file graph2d.h.
Constructor & Destructor Documentation
csGraphics2D::csGraphics2D | ( | iBase * | ) |
Create csGraphics2D object.
virtual csGraphics2D::~csGraphics2D | ( | ) | [virtual] |
Destroy csGraphics2D object.
Member Function Documentation
virtual void csGraphics2D::AllowResize | ( | bool | ) | [inline, virtual] |
virtual bool csGraphics2D::BeginDraw | ( | ) | [virtual] |
This routine should be called before any draw operations.
It should return true if graphics context is ready.
virtual void csGraphics2D::Blit | ( | int | x, | |
int | y, | |||
int | width, | |||
int | height, | |||
unsigned char const * | data | |||
) | [virtual] |
Blit a memory block. Format of the image is RGBA in bytes. Row by row.
virtual void csGraphics2D::ChangeDepth | ( | int | d | ) | [virtual] |
Change the depth of the canvas.
virtual void csGraphics2D::Clear | ( | int | color | ) | [virtual] |
Clear backbuffer.
virtual void csGraphics2D::ClearAll | ( | int | color | ) | [virtual] |
Clear all video pages.
virtual bool csGraphics2D::ClipLine | ( | float & | x1, | |
float & | y1, | |||
float & | x2, | |||
float & | y2, | |||
int | xmin, | |||
int | ymin, | |||
int | xmax, | |||
int | ymax | |||
) | [virtual] |
Clip a line against given rectangle Function returns true if line is not visible.
virtual void csGraphics2D::Close | ( | ) | [virtual] |
(*) Close graphics system
virtual bool csGraphics2D::DoubleBuffer | ( | bool | Enable | ) | [virtual] |
Enable or disable double buffering; return TRUE if supported.
virtual void csGraphics2D::DrawBox | ( | int | x, | |
int | y, | |||
int | w, | |||
int | h, | |||
int | color | |||
) | [virtual] |
Draw a box of given width and height.
virtual void csGraphics2D::DrawLine | ( | float | x1, | |
float | y1, | |||
float | x2, | |||
float | y2, | |||
int | color | |||
) | [virtual] |
Draw a line.
virtual void csGraphics2D::DrawPixel | ( | int | x, | |
int | y, | |||
int | color | |||
) | [inline, virtual] |
static void csGraphics2D::DrawPixel16 | ( | csGraphics2D * | This, | |
int | x, | |||
int | y, | |||
int | color | |||
) | [static, protected] |
Draw a pixel in 16-bit modes.
static void csGraphics2D::DrawPixel32 | ( | csGraphics2D * | This, | |
int | x, | |||
int | y, | |||
int | color | |||
) | [static, protected] |
Draw a pixel in 32-bit modes.
static void csGraphics2D::DrawPixel8 | ( | csGraphics2D * | This, | |
int | x, | |||
int | y, | |||
int | color | |||
) | [static, protected] |
Default drawing routines for 8-bit and 16-bit modes If a system port has its own routines, it should assign their addresses to respective pointers.
Draw a pixel in 8-bit modes
virtual void csGraphics2D::FinishDraw | ( | ) | [virtual] |
This routine should be called when you finished drawing.
virtual void csGraphics2D::FreeArea | ( | csImageArea * | Area | ) | [virtual] |
Free storage allocated for a subarea of screen.
virtual void csGraphics2D::GetClipRect | ( | int & | xmin, | |
int & | ymin, | |||
int & | xmax, | |||
int & | ymax | |||
) | [virtual] |
Query clipping rectangle.
virtual bool csGraphics2D::GetDoubleBufferState | ( | ) | [virtual] |
Return current double buffering state.
virtual iFontServer* csGraphics2D::GetFontServer | ( | ) | [inline, virtual] |
virtual bool csGraphics2D::GetFullScreen | ( | ) | [inline, virtual] |
virtual const char* csGraphics2D::GetName | ( | ) | const [virtual] |
Get the name of this canvas.
virtual iNativeWindow* csGraphics2D::GetNativeWindow | ( | ) | [virtual] |
Return the Native Window interface for this canvas (if it has one).
virtual int csGraphics2D::GetPage | ( | ) | [virtual] |
Get active videopage number (starting from zero).
virtual int csGraphics2D::GetPalEntryCount | ( | ) | [inline, virtual] |
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.
virtual csRGBpixel* csGraphics2D::GetPalette | ( | ) | [inline, virtual] |
virtual void csGraphics2D::GetPixel | ( | int | x, | |
int | y, | |||
uint8 & | oR, | |||
uint8 & | oG, | |||
uint8 & | oB, | |||
uint8 & | oA | |||
) | [virtual] |
As GetPixel() above, but with alpha.
Query pixel R,G,B at given screen location.
virtual unsigned char* csGraphics2D::GetPixelAt | ( | int | x, | |
int | y | |||
) | [inline, virtual] |
static unsigned char* csGraphics2D::GetPixelAt16 | ( | csGraphics2D * | This, | |
int | x, | |||
int | y | |||
) | [static, protected] |
Return address of a 16-bit pixel.
static unsigned char* csGraphics2D::GetPixelAt32 | ( | csGraphics2D * | This, | |
int | x, | |||
int | y | |||
) | [static, protected] |
Return address of a 32-bit pixel.
static unsigned char* csGraphics2D::GetPixelAt8 | ( | csGraphics2D * | This, | |
int | x, | |||
int | y | |||
) | [static, protected] |
Return address of a 8-bit pixel.
virtual int csGraphics2D::GetPixelBytes | ( | ) | [inline, virtual] |
Return the number of bytes for every pixel.
This function is equivalent to the PixelBytes field that you get from GetPixelFormat().
virtual csPixelFormat const* csGraphics2D::GetPixelFormat | ( | ) | [inline, virtual] |
virtual bool csGraphics2D::HandleEvent | ( | iEvent & | ) | [virtual] |
Event handler for plugin.
virtual bool csGraphics2D::Initialize | ( | iObjectRegistry * | ) | [virtual] |
Initialize the plugin.
virtual bool csGraphics2D::Open | ( | ) | [virtual] |
(*) Open graphics system (set videomode, open window etc)
virtual bool csGraphics2D::PerformExtension | ( | char const * | command, | |
... | ||||
) | [virtual] |
Perform a system specific extension.
Return false if extension not supported.
virtual bool csGraphics2D::PerformExtensionV | ( | char const * | command, | |
va_list | ||||
) | [virtual] |
Perform a system specific extension.
Return false if extension not supported.
virtual void csGraphics2D::Print | ( | csRect const * | = 0 |
) | [inline, virtual] |
virtual bool csGraphics2D::Resize | ( | int | w, | |
int | h | |||
) | [virtual] |
Resize the canvas.
virtual void csGraphics2D::RestoreArea | ( | csImageArea * | Area, | |
bool | Free = true | |||
) | [virtual] |
Restore a subarea of screen saved with SaveArea().
virtual csImageArea* csGraphics2D::SaveArea | ( | int | x, | |
int | y, | |||
int | w, | |||
int | h | |||
) | [virtual] |
Save a subarea of screen area into the variable Data.
Storage is allocated in this call, you should either FreeArea() it after usage or RestoreArea() it.
Do a screenshot: return a new iImage object.
virtual void csGraphics2D::SetClipRect | ( | int | xmin, | |
int | ymin, | |||
int | xmax, | |||
int | ymax | |||
) | [virtual] |
Set clipping rectangle.
virtual void csGraphics2D::SetFullScreen | ( | bool | b | ) | [virtual] |
Change the fullscreen state of the canvas.
virtual bool csGraphics2D::SetMouseCursor | ( | iImage * | image, | |
const csRGBcolor * | keycolor = 0 , |
|||
int | hotspot_x = 0 , |
|||
int | hotspot_y = 0 , |
|||
csRGBcolor | fg = csRGBcolor(255, 255, 255) , |
|||
csRGBcolor | bg = csRGBcolor(0, 0, 0) | |||
) | [virtual] |
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'
virtual bool csGraphics2D::SetMouseCursor | ( | csMouseCursorID | iShape | ) | [virtual] |
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 and iBitmap != 0, shape should be set to the bitmap passed as second argument; otherwise cursor should be set to its nearest system equivalent depending on iShape argument.
virtual bool csGraphics2D::SetMousePosition | ( | int | x, | |
int | y | |||
) | [virtual] |
Set mouse cursor position; return success status.
virtual void csGraphics2D::SetRGB | ( | int | i, | |
int | r, | |||
int | g, | |||
int | b | |||
) | [virtual] |
(*) Set a color index to given R,G,B (0..255) values
virtual void csGraphics2D::Write | ( | iFont * | font, | |
int | x, | |||
int | y, | |||
int | fg, | |||
int | bg, | |||
const wchar_t * | text, | |||
uint | flags = 0 | |||
) | [virtual] |
Write a text string into the back buffer.
virtual void csGraphics2D::Write | ( | iFont * | font, | |
int | x, | |||
int | y, | |||
int | fg, | |||
int | bg, | |||
const char * | text, | |||
uint | flags = 0 | |||
) | [virtual] |
Write a text string into the back buffer.
Member Data Documentation
void(* csGraphics2D::_DrawPixel)(csGraphics2D *This, int x, int y, int color) |
To facilitate multiple pixel formats, the most critical drawing routines are defined as pointers to functions, not as virtual methods.
This allows deciding at run-time which function we will choose. Draw a pixel
unsigned char*(* csGraphics2D::_GetPixelAt)(csGraphics2D *This, int x, int y) |
(*) Get address of video RAM at given x,y coordinates
The counter that is incremented inside BeginDraw and decremented in FinishDraw().
unsigned char* csGraphics2D::Memory |
bool csGraphics2D::PaletteAlloc[256] |
int csGraphics2D::refreshRate [protected] |
bool csGraphics2D::vsync [protected] |
The documentation for this class was generated from the following file:
- csplugincommon/canvas/graph2d.h
Generated for Crystal Space 1.4.0 by doxygen 1.5.8