In file libs/cs2d/common/graph2d.h:

## class csGraphics2D

> This is the base class for 2D renderer

## Inheritance:

### Public Fields

static int Font
  Current font number
static bool FullScreen
  True if visual is full-screen
static RGBpaletteEntry Palette[256]
  256-color palette
static bool PaletteAlloc[256]
  true if some palette entry is already allocated
static int Width
  The width, height and depth of visual

### Public Methods

static void (*DrawPixel)(int x, int y, int color)
  Draw a pixel
static void (*DrawSprite)(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
  Draw a sprite (possibly rescaled to given width (sw) and height (sh)) using given rectangle from given texture
static unsigned char* (*GetPixelAt)(int x, int y)
  (*) Get address of video RAM at given x,y coordinates
static void (*WriteChar)(int x, int y, int fg, int bg, char c)
  Write a single character
virtual bool BeginDraw()
  This routine should be called before any draw operations
virtual void Clear(int color)
  Clear backbuffer
void ClearAll(int color)
  Clear all video pages
static 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(ISystem* piSystem)
  Create csGraphics2D object
virtual bool DoubleBuffer()
  Return current double buffering state
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
static void DrawPixel8(int x, int y, int color)
  Draw a pixel in 8-bit modes
virtual void FinishDraw()
  This routine should be called when you finished drawing
virtual void FreeArea(ImageArea *Area)
  Free storage allocated for a subarea of screen
virtual void GetClipRect(int &xmin, int &ymin, int &xmax, int &ymax)
  Query clipping rectangle
int GetNumPalEntries()
  Return the number of palette entries that can be modified
virtual int GetPage()
  Get active videopage number (starting from zero)
int GetPixelBytes()
  Return the number of bytes for every pixel
csPixelFormat* GetPixelFormat()
  Return information about about the pixel format
virtual void GetStringError(HRESULT hRes, char* szValue)
virtual int GetTextHeight(int Font)
  Get the height of given font
virtual int GetTextWidth(int Font, char *text)
  Get the width of a string if it would be drawn with given font
virtual void Initialize()
virtual bool Open(char *Title)
  (*) Open graphics system (set videomode, open window etc)
virtual bool PerformExtension(char* args)
  Perform a system specific extension
virtual void Print(csRect *area = NULL)
  (*) Flip video pages (or dump backbuffer into framebuffer).
virtual void RestoreArea(ImageArea *Area, bool Free = true)
  Restore a subarea of screen saved with SaveArea()
virtual bool SaveArea(ImageArea *&Area, int x, int y, int w, int h)
  Save a subarea of screen area into the variable Data
virtual void SetClipRect(int xmin, int ymin, int xmax, int ymax)
  Set clipping rectangle
virtual bool SetMouseCursor(int iShape, ITextureHandle *hBitmap)
  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
void SysPrintf(int mode, char* text, ...)
virtual void Write(int x, int y, int fg, int bg, char *text)
  Write a text string into the back buffer
virtual ~csGraphics2D()
  Destroy csGraphics2D object

### Public

  To facilitate multiple pixel formats, the most critical drawing routines are defined as pointers to functions, not as virtual methods

### Protected Fields

static int ClipX1
  The clipping rectangle
static int* LineAddress
  Keep a array of Y*width to avoid multiplications
static unsigned char* Memory
  Most systems have a pointer to (real or pseudo) video RAM
static csPixelFormat pfmt
  The pixel format
static ISystem* system
  The system driver.

### Protected Methods

void complete_pixel_format()
  Little helper function to complete a csPixelFormat structure given that the masks are correctly filled in
static void DrawPixel16(int x, int y, int color)
  Draw a pixel in 16-bit modes
static void DrawPixel32(int x, int y, int color)
  Draw a pixel in 32-bit modes
static void DrawSprite16(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
  Draw a sprite on 16-bit display using a rectangle from given texture
static void DrawSprite32(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
  Draw a sprite on 32-bit display using a rectangle from given texture
static void DrawSprite8(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
  Draw a sprite on 8-bit display using a rectangle from given texture
static unsigned char* GetPixelAt16(int x, int y)
  Return address of a 16-bit pixel
static unsigned char* GetPixelAt32(int x, int y)
  Return address of a 32-bit pixel
static unsigned char* GetPixelAt8(int x, int y)
  Return address of a 8-bit pixel
static void WriteChar16(int x, int y, int fg, int bg, char c)
  Write a character in 16-bit modes
static void WriteChar32(int x, int y, int fg, int bg, char c)
  Write a character in 32-bit modes
static void WriteChar8(int x, int y, int fg, int bg, char c)
  Write a character in 8-bit modes

### 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

## Documentation

> This is the base class for 2D renderer. System-dependent ports should derive their own SysGraphics2D 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.

`static int ClipX1`
  The clipping rectangle

`static csPixelFormat pfmt`
  The pixel format

`static unsigned char* Memory`
  Most systems have a pointer to (real or pseudo) video RAM

`static int* LineAddress`
  Keep a array of Y*width to avoid multiplications

`static ISystem* system`
  The system driver.

`static int Font`
  Current font number

`static int Width`
  The width, height and depth of visual

`static bool FullScreen`
  True if visual is full-screen

`static RGBpaletteEntry Palette[256]`
  256-color palette

`static bool PaletteAlloc[256]`
  true if some palette entry is already allocated

`csGraphics2D(ISystem* piSystem)`
  Create csGraphics2D object

`virtual ~csGraphics2D()`
  Destroy csGraphics2D object

`virtual void Initialize()`

`virtual bool Open(char *Title)`
  (*) Open graphics system (set videomode, open window etc)

`virtual void Close()`
  (*) Close graphics system

`virtual void SetClipRect(int xmin, int ymin, int xmax, int ymax)`
  Set clipping rectangle

`virtual void GetClipRect(int &xmin, int &ymin, int &xmax, int &ymax)`
  Query clipping rectangle

`virtual bool BeginDraw()`
  This routine should be called before any draw operations. It should return true if graphics context is ready.

`virtual void FinishDraw()`
  This routine should be called when you finished drawing

`virtual void Print(csRect *area = NULL)`
  (*) Flip video pages (or dump backbuffer into framebuffer).

`virtual int GetPage()`
  Get active videopage number (starting from zero)

`virtual bool DoubleBuffer(bool Enable)`
  Enable or disable double buffering; return TRUE if supported

`virtual bool DoubleBuffer()`
  Return current double buffering state

`void ClearAll(int color)`
  Clear all video pages

``
  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.

`virtual void Clear(int color)`
  Clear backbuffer

`static void (*DrawPixel)(int x, int y, int color)`
  Draw a pixel

`virtual void DrawLine(float x1, float y1, float x2, float y2, int color)`
  Draw a line

`virtual void DrawBox(int x, int y, int w, int h, int color)`
  Draw a box of given width and height

`virtual void SetRGB(int i, int r, int g, int b)`
  (*) Set a color index to given R,G,B (0..255) values

`virtual void Write(int x, int y, int fg, int bg, char *text)`
  Write a text string into the back buffer

`static void (*WriteChar)(int x, int y, int fg, int bg, char c)`
  Write a single character

`virtual int GetTextWidth(int Font, char *text)`
  Get the width of a string if it would be drawn with given font

`virtual int GetTextHeight(int Font)`
  Get the height of given font

`static void (*DrawSprite)(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)`
  Draw a sprite (possibly rescaled to given width (sw) and height (sh)) using given rectangle from given texture

`static unsigned char* (*GetPixelAt)(int x, int y)`
  (*) Get address of video RAM at given x,y coordinates

`int GetNumPalEntries()`
  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.

`int GetPixelBytes()`
  Return the number of bytes for every pixel. This function is equivalent to the PixelBytes field that you get from GetPixelFormat.

`csPixelFormat* GetPixelFormat()`
  Return information about about the pixel format

`virtual bool SaveArea(ImageArea *&Area, int x, int y, int w, int h)`
  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.

`virtual void RestoreArea(ImageArea *Area, bool Free = true)`
  Restore a subarea of screen saved with SaveArea()

`virtual void FreeArea(ImageArea *Area)`
  Free storage allocated for a subarea of screen

`static 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 bool SetMousePosition(int x, int y)`
  Set mouse cursor position; return success status

`virtual bool SetMouseCursor(int iShape, ITextureHandle *hBitmap)`
  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 != NULL, 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 PerformExtension(char* args)`
  Perform a system specific extension. Return false if extension not supported.

`void SysPrintf(int mode, char* text, ...)`

`virtual void GetStringError(HRESULT hRes, char* szValue)`

`void complete_pixel_format()`
  Little helper function to complete a csPixelFormat structure given that the masks are correctly filled in

``
  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 void DrawPixel8(int x, int y, int color)`
  Draw a pixel in 8-bit modes

`static void WriteChar8(int x, int y, int fg, int bg, char c)`
  Write a character in 8-bit modes

`static unsigned char* GetPixelAt8(int x, int y)`
  Return address of a 8-bit pixel

`static void DrawSprite8(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)`
  Draw a sprite on 8-bit display using a rectangle from given texture

`static void DrawPixel16(int x, int y, int color)`
  Draw a pixel in 16-bit modes

`static void WriteChar16(int x, int y, int fg, int bg, char c)`
  Write a character in 16-bit modes

`static unsigned char* GetPixelAt16(int x, int y)`
  Return address of a 16-bit pixel

`static void DrawSprite16(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)`
  Draw a sprite on 16-bit display using a rectangle from given texture

`static void DrawPixel32(int x, int y, int color)`
  Draw a pixel in 32-bit modes

`static void WriteChar32(int x, int y, int fg, int bg, char c)`
  Write a character in 32-bit modes

`static unsigned char* GetPixelAt32(int x, int y)`
  Return address of a 32-bit pixel

`static void DrawSprite32(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)`
  Draw a sprite on 32-bit display using a rectangle from given texture

Direct child classes:
  csGraphics2DXLib
  csGraphics2DSVGALib
  csGraphics2DOS2DIVE
  csGraphics2DMac
  csGraphics2DMac
  csGraphics2DGlideX
  csGraphics2DGlideCommon
  csGraphics2DGLCommon
  csGraphics2DGGI
  csGraphics2DDOSRAW
  csGraphics2DDDraw6
  csGraphics2DDDraw3
  csGraphics2DBeLib
  csGraphics2DAA
  SysGraphics2D
  SysGraphics2D

alphabetic index hierarchy of classes

this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de