CrystalSpace

Public API Reference

iGraphics2D Struct Reference
[2D]

This is the interface for 2D renderer. More...

#include <ivideo/graph2d.h>

Inheritance diagram for iGraphics2D:

List of all members.

Public Member Functions

virtual bool BeginDraw ()=0
 This routine should be called before any draw operations.
virtual void Blit (int x, int y, int width, int height, unsigned char const *data)=0
 Blit a memory block. Format of the image is RGBA in bytes. Row by row.
virtual void Clear (int color)=0
 Clear backbuffer.
virtual void ClearAll (int color)=0
 Clear all video pages.
virtual bool ClipLine (float &x1, float &y1, float &x2, float &y2, int xmin, int ymin, int xmax, int ymax)=0
 Clip a line against given rectangle.
virtual void Close ()=0
 Close the device.
virtual void DrawBox (int x, int y, int w, int h, int color)=0
 Draw a box.
virtual void DrawBoxProjected (const csBox3 &box, const csTransform &object2camera, const CS::Math::Matrix4 &projection, int color)=0
 Draw a box expressed in camera space.
virtual void DrawLine (float x1, float y1, float x2, float y2, int color)=0
 Draw a line.
virtual void DrawLineProjected (const csVector3 &v1, const csVector3 &v2, float fov, float aspect, int color)=0
 Draw a line between two points expressed in camera space.
virtual void DrawLineProjected (const csVector3 &v1, const csVector3 &v2, const CS::Math::Matrix4 &projection, int color)=0
 Draw a line between two points expressed in camera space.
virtual void DrawLineProjected (const csVector3 &v1, const csVector3 &v2, float fov, int color)=0
 Draw a line between two points expressed in camera space.
virtual void DrawPixel (int x, int y, int color)=0
 Draw a pixel.
virtual void DrawPixels (csPixelCoord const *pixels, int num_pixels, int color)=0
 Draw an array of pixel coordinates with the given color.
virtual int FindRGB (int r, int g, int b, int a=255)=0
 Find an RGB (0..255) color.
virtual void FinishDraw ()=0
 This routine should be called when you finished drawing.
virtual void GetClipRect (int &nMinX, int &nMinY, int &nMaxX, int &nMaxY)=0
 Retrieve the clipping rectangle.
virtual iFontServerGetFontServer ()=0
 Get the active font server (does not do IncRef()).
virtual int GetHeight ()=0
 Return the height of the viewport.
virtual const char * GetHWGLVersion ()=0
 Get a string containing the OpenGL version.
virtual const char * GetHWRenderer ()=0
 Get a string containing the hardware renderer.
virtual const char * GetHWVendor ()=0
 Get a string containing the vendor info.
virtual void GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB, uint8 &oA)=0
 As GetPixel() above, but with alpha.
virtual void GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB)=0
 Query pixel R,G,B at given screen location.
virtual void GetRGB (int color, int &r, int &g, int &b, int &a)=0
 Retrieve the R,G,B,A tuple for a given color number.
virtual void GetRGB (int color, int &r, int &g, int &b)=0
 Retrieve the R,G,B tuple for a given color number.
virtual void GetViewport (int &left, int &top, int &width, int &height)=0
 Get the currently set viewport.
virtual int GetWidth ()=0
 Return the width of the viewport.
virtual bool Open ()=0
 Open the device.
bool PerformExtension (char const *command,...)
 Perform a system specific exension.
virtual bool PerformExtensionV (char const *command, va_list)=0
 Perform a system specific exension.
virtual bool Resize (int w, int h)=0
 Resize the canvas.
virtual bool ScreenShot (unsigned char *buffer)=0
 Do a screenshot in preallocated buffer.
virtual csPtr< iImageScreenShot ()=0
 Do a screenshot: return a new iImage object.
virtual void SetClipRect (int nMinX, int nMinY, int nMaxX, int nMaxY)=0
 Set the clipping rectangle.
virtual void SetViewport (int left, int top, int width, int height)=0
 Set the viewport (the rectangle of the framebuffer to draw to).
virtual void Write (iFont *font, int x, int y, int fg, int bg, const wchar_t *str, uint flags=0)=0
 Write a text string into the back buffer.
virtual void Write (iFont *font, int x, int y, int fg, int bg, const char *str, uint flags=0)=0
 Write a text string into the back buffer.

Detailed Description

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.

Main creators of instances implementing this interface:

Main ways to get pointers to this interface:

Main users of this interface:

Definition at line 97 of file graph2d.h.


Member Function Documentation

virtual bool iGraphics2D::BeginDraw (  )  [pure virtual]

This routine should be called before any draw operations.

It should return true if graphics context is ready.

Implemented in CS::PluginCommon::Graphics2DCommon, and CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::Blit ( int  x,
int  y,
int  width,
int  height,
unsigned char const *  data 
) [pure virtual]

Blit a memory block. Format of the image is RGBA in bytes. Row by row.

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::Clear ( int  color  )  [pure virtual]
virtual void iGraphics2D::ClearAll ( int  color  )  [pure virtual]

Clear all video pages.

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual bool iGraphics2D::ClipLine ( float &  x1,
float &  y1,
float &  x2,
float &  y2,
int  xmin,
int  ymin,
int  xmax,
int  ymax 
) [pure virtual]

Clip a line against given rectangle.

Function returns true if line is not visible.

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual void iGraphics2D::Close (  )  [pure virtual]
virtual void iGraphics2D::DrawBox ( int  x,
int  y,
int  w,
int  h,
int  color 
) [pure virtual]

Draw a box.

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::DrawBoxProjected ( const csBox3 box,
const csTransform object2camera,
const CS::Math::Matrix4 projection,
int  color 
) [pure virtual]

Draw a box expressed in camera space.

Parameters:
box The box to be drawn.
v2 object2camera The transform from the box space to the camera space.
projection Projection matrix to use for the camera. Typically, you would want to use the one returned by iCamera::GetProjectionMatrix().
color Color of the line. The color value can be obtained through FindRGB().

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::DrawLine ( float  x1,
float  y1,
float  x2,
float  y2,
int  color 
) [pure virtual]

Draw a line.

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::DrawLineProjected ( const csVector3 v1,
const csVector3 v2,
float  fov,
float  aspect,
int  color 
) [pure virtual]

Draw a line between two points expressed in camera space.

Warning:
This version of the method will only work for iPerspectiveCamera's. For other camera's, you should use the other DrawLineProjected() method.
Parameters:
v1 Start point of the line.
v2 End point of the line.
fov Field of View to use for the projection. Typically, you would want to use the one returned by iPerspectiveCamera::GetVerticalFOV().
aspect Aspect ratio to use for the projection. Typically, you would want to use the one returned by iPerspectiveCamera::GetAspectRatio().
color Color of the line. The color value can be obtained through FindRGB().

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::DrawLineProjected ( const csVector3 v1,
const csVector3 v2,
const CS::Math::Matrix4 projection,
int  color 
) [pure virtual]

Draw a line between two points expressed in camera space.

Parameters:
v1 Start point of the line.
v2 End point of the line.
projection Projection matrix to use for the camera. Typically, you would want to use the one returned by iCamera::GetProjectionMatrix().
color Color of the line. The color value can be obtained through FindRGB().

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::DrawLineProjected ( const csVector3 v1,
const csVector3 v2,
float  fov,
int  color 
) [pure virtual]

Draw a line between two points expressed in camera space.

Warning:
This version of the method will only work for iPerspectiveCamera's. For other camera's, you should use the other DrawLineProjected() method.
Parameters:
v1 Start point of the line.
v2 End point of the line.
fov Field of view in pixels. Typically, you would want to use the one returned by iPerspectiveCamera::GetVerticalFOV() times iGraphics2D::GetHeight().
color Color of the line. The color value can be obtained through FindRGB().
Deprecated:
Deprecated in 2.2. Use the other versions of DrawLineProjected() instead

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::DrawPixel ( int  x,
int  y,
int  color 
) [pure virtual]

Draw a pixel.

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::DrawPixels ( csPixelCoord const *  pixels,
int  num_pixels,
int  color 
) [pure virtual]

Draw an array of pixel coordinates with the given color.

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual int iGraphics2D::FindRGB ( int  r,
int  g,
int  b,
int  a = 255 
) [pure virtual]

Find an RGB (0..255) color.

The actual color bytes are returned.

Use returned value for color arguments in iGraphics2D.

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual void iGraphics2D::FinishDraw (  )  [pure virtual]

This routine should be called when you finished drawing.

Implemented in CS::PluginCommon::Graphics2DCommon, and CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::GetClipRect ( int &  nMinX,
int &  nMinY,
int &  nMaxX,
int &  nMaxY 
) [pure virtual]

Retrieve the clipping rectangle.

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual iFontServer* iGraphics2D::GetFontServer (  )  [pure virtual]

Get the active font server (does not do IncRef()).

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual int iGraphics2D::GetHeight (  )  [pure virtual]

Return the height of the viewport.

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual const char* iGraphics2D::GetHWGLVersion (  )  [pure virtual]

Get a string containing the OpenGL version.

Implemented in CS::PluginCommon::Graphics2DCommon, and CS::PluginCommon::GL::Graphics2DCommon.

virtual const char* iGraphics2D::GetHWRenderer (  )  [pure virtual]

Get a string containing the hardware renderer.

Implemented in CS::PluginCommon::Graphics2DCommon, and CS::PluginCommon::GL::Graphics2DCommon.

virtual const char* iGraphics2D::GetHWVendor (  )  [pure virtual]

Get a string containing the vendor info.

Implemented in CS::PluginCommon::Graphics2DCommon, and CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::GetPixel ( int  x,
int  y,
uint8 &  oR,
uint8 &  oG,
uint8 &  oB,
uint8 &  oA 
) [pure virtual]

As GetPixel() above, but with alpha.

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::GetPixel ( int  x,
int  y,
uint8 &  oR,
uint8 &  oG,
uint8 &  oB 
) [pure virtual]

Query pixel R,G,B at given screen location.

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::GetRGB ( int  color,
int &  r,
int &  g,
int &  b,
int &  a 
) [pure virtual]

Retrieve the R,G,B,A tuple for a given color number.

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual void iGraphics2D::GetRGB ( int  color,
int &  r,
int &  g,
int &  b 
) [pure virtual]

Retrieve the R,G,B tuple for a given color number.

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual void iGraphics2D::GetViewport ( int &  left,
int &  top,
int &  width,
int &  height 
) [pure virtual]

Get the currently set viewport.

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual int iGraphics2D::GetWidth (  )  [pure virtual]

Return the width of the viewport.

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual bool iGraphics2D::Open (  )  [pure virtual]
bool iGraphics2D::PerformExtension ( char const *  command,
  ... 
) [inline]

Perform a system specific exension.

The command is a string; any arguments may follow. There is no way to guarantee the uniquiness of commands, so please try to use descriptive command names rather than "a", "b" and so on...

Definition at line 208 of file graph2d.h.

virtual bool iGraphics2D::PerformExtensionV ( char const *  command,
va_list   
) [pure virtual]

Perform a system specific exension.

Just like PerformExtension() except that the command arguments are passed as a `va_list'.

Implemented in CS::PluginCommon::Graphics2DCommon, and CS::PluginCommon::GL::Graphics2DCommon.

virtual bool iGraphics2D::Resize ( int  w,
int  h 
) [pure virtual]
virtual bool iGraphics2D::ScreenShot ( unsigned char *  buffer  )  [pure virtual]

Do a screenshot in preallocated buffer.

Buffer should have size width*height*4. Returns true on success or false on failure.

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual csPtr<iImage> iGraphics2D::ScreenShot (  )  [pure virtual]

Do a screenshot: return a new iImage object.

Implemented in CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::SetClipRect ( int  nMinX,
int  nMinY,
int  nMaxX,
int  nMaxY 
) [pure virtual]

Set the clipping rectangle.

The clipping rectangle is inclusive the top and left edges and exclusive for the right and bottom borders.

Implemented in CS::PluginCommon::Graphics2DCommon, and CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::SetViewport ( int  left,
int  top,
int  width,
int  height 
) [pure virtual]

Set the viewport (the rectangle of the framebuffer to draw to).

Parameters:
left Left of the viewport. X=0 will map to this.
top Right of the viewport. Y=0 will map to this.
width Width of the viewport.
height Height of the viewport.

Implemented in CS::PluginCommon::Graphics2DCommon, and CS::PluginCommon::GL::Graphics2DCommon.

virtual void iGraphics2D::Write ( iFont font,
int  x,
int  y,
int  fg,
int  bg,
const wchar_t *  str,
uint  flags = 0 
) [pure virtual]

Write a text string into the back buffer.

A value of -1 for bg color will not draw the background.

Remarks:
For transparent backgrounds, it is recommended to obtain a color value from FindRGB() that has the same R, G, B components as the foreground color, but an alpha component of 0.

Implemented in CS::PluginCommon::Graphics2DCommon.

virtual void iGraphics2D::Write ( iFont font,
int  x,
int  y,
int  fg,
int  bg,
const char *  str,
uint  flags = 0 
) [pure virtual]

Write a text string into the back buffer.

A value of -1 for bg color will not draw the background.

Remarks:
str is expected to be UTF-8 encoded.
For transparent backgrounds, it is recommended to obtain a color value from FindRGB() that has the same R, G, B components as the foreground color, but an alpha component of 0.

Implemented in CS::PluginCommon::Graphics2DCommon.


The documentation for this struct was generated from the following file:

Generated for Crystal Space 2.1 by doxygen 1.6.1