CrystalSpace

Public API Reference

CS::PluginCommon::GL::Graphics2DCommon Class Reference

Basic OpenGL version of the 2D driver class. More...

#include <csplugincommon/opengl/glcommon2d.h>

Inheritance diagram for CS::PluginCommon::GL::Graphics2DCommon:

List of all members.

Public Member Functions

virtual bool BeginDraw ()
 This routine should be called before any draw operations.
virtual void Blit (int x, int y, int w, int h, unsigned char const *data)
 Blit.
virtual void Clear (int color)
 Clear the screen with color.
virtual void Close ()
 (*) Close graphics system
virtual bool DebugCommand (const char *cmd)
 Execute a debug command.
virtual bool DoubleBuffer (bool Enable)
 Enable or disable double buffering; returns success status.
virtual void DrawBox (int x, int y, int w, int h, int color)
 Draw a box.
virtual void DrawBoxProjected (const csBox3 &box, const csTransform &object2camera, const CS::Math::Matrix4 &projection, int color)
 Draw a box in camera space.
virtual void DrawLine (float x1, float y1, float x2, float y2, int color)
 Draw a line.
virtual void DrawLineProjected (const csVector3 &v1, const csVector3 &v2, const CS::Math::Matrix4 &projection, int color)
 Draw a line in camera space.
virtual void DrawLineProjected (const csVector3 &v1, const csVector3 &v2, float fov, float aspect, int color)
 Draw a line in camera space.
virtual void DrawLineProjected (const csVector3 &v1, const csVector3 &v2, float viewHeight, int color)
 Draw a line in camera space.
virtual void DrawPixel (int x, int y, int color)
 Draw a pixel.
virtual void DrawPixels (csPixelCoord const *pixels, int num_pixels, int color)
 Draw a series of pixels.
virtual void FinishDraw ()
 This routine should be called when you finished drawing.
virtual bool GetDoubleBufferState ()
 Get the double buffer state.
virtual const char * GetHWGLVersion ()
 Get a string containing the OpenGL version.
virtual const char * GetHWRenderer ()
 Get a string containing the hardware renderer.
virtual const char * GetHWVendor ()
 Get a string containing the vendor info.
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.
 Graphics2DCommon ()
 Constructor does little, most initialization stuff happens in Initialize().
virtual bool Initialize (iObjectRegistry *object_reg)
 Initialize the plugin.
virtual bool Open ()
 Initialize font cache, texture cache, prints renderer name and version.
virtual bool PerformExtensionV (char const *command, va_list)
 Perform extension commands.
virtual bool Resize (int width, int height)
 Resize the canvas.
virtual bool ScreenShot (unsigned char *buffer)
 Do a screenshot in preallocated buffer, return success or failure.
virtual csPtr< iImageScreenShot ()
 Do a screenshot: return a new iImage object.
virtual void SetClipRect (int xmin, int ymin, int xmax, int ymax)
 Set clipping rectangle.
void SetViewport (int left, int top, int width, int height)
 Set the viewport (the rectangle of the framebuffer to draw to).
virtual ~Graphics2DCommon ()
 Clear font cache etc.
iGLDriverDatabase implementation



void ReadDatabase (iDocumentNode *dbRoot, int configPriority=iConfigManager::ConfigPriorityPlugin+20, const char *phase=0)
 Read a custom driver database.

Protected Member Functions

void DecomposeColor (int iColor, float &oR, float &oG, float &oB, float &oA)
 Same but uses floating-point format.
void DecomposeColor (int iColor, GLubyte &oR, GLubyte &oG, GLubyte &oB, GLubyte &oA)
 Decompose a color ID into r,g,b components.
bool DrawLineNearClip (csVector3 &v1, csVector3 &v2)
 Clip line to be drawn by DrawLine to SMALL_Z.
void OpenDriverDB (const char *phase=0)
 Open default driver database.
void setGLColorfromint (int color)
 Set up current GL RGB color from a packed color format.

Protected Attributes

csGLDriverDatabase driverdb
 Driver database.
csGLExtensionManager ext
 Extension manager.
bool multiFavorQuality
 Multisample samples.
csGLStateCachestatecache
 Cache for GL states.

Detailed Description

Basic OpenGL version of the 2D driver class.

You can look at one of the OpenGL canvas classes as an example of how to inherit and use this class. In short, inherit from this common class instead of from csGraphics2D, and override all the functions you normally would except for the 2D drawing functions, which are supplied for you here. That way all OpenGL drawing functions are unified over platforms, so that a fix or improvement will be inherited by all platforms instead of percolating via people copying code over.

Definition at line 63 of file glcommon2d.h.


Constructor & Destructor Documentation

CS::PluginCommon::GL::Graphics2DCommon::Graphics2DCommon (  ) 

Constructor does little, most initialization stuff happens in Initialize().

Reimplemented from CS::PluginCommon::Graphics2DCommon.

virtual CS::PluginCommon::GL::Graphics2DCommon::~Graphics2DCommon (  )  [virtual]

Clear font cache etc.

Reimplemented from CS::PluginCommon::Graphics2DCommon.


Member Function Documentation

virtual bool CS::PluginCommon::GL::Graphics2DCommon::BeginDraw (  )  [virtual]

This routine should be called before any draw operations.

It should return true if graphics context is ready.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

virtual void CS::PluginCommon::GL::Graphics2DCommon::Blit ( int  x,
int  y,
int  w,
int  h,
unsigned char const *  data 
) [virtual]

Blit.

Implements iGraphics2D.

virtual void CS::PluginCommon::GL::Graphics2DCommon::Clear ( int  color  )  [virtual]

Clear the screen with color.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

virtual void CS::PluginCommon::GL::Graphics2DCommon::Close (  )  [virtual]

(*) Close graphics system

Reimplemented from CS::PluginCommon::Graphics2DCommon.

virtual bool CS::PluginCommon::GL::Graphics2DCommon::DebugCommand ( const char *  cmd  )  [virtual]

Execute a debug command.

void CS::PluginCommon::GL::Graphics2DCommon::DecomposeColor ( int  iColor,
float &  oR,
float &  oG,
float &  oB,
float &  oA 
) [protected]

Same but uses floating-point format.

void CS::PluginCommon::GL::Graphics2DCommon::DecomposeColor ( int  iColor,
GLubyte &  oR,
GLubyte &  oG,
GLubyte &  oB,
GLubyte &  oA 
) [protected]

Decompose a color ID into r,g,b components.

virtual bool CS::PluginCommon::GL::Graphics2DCommon::DoubleBuffer ( bool  Enable  )  [inline, virtual]

Enable or disable double buffering; returns success status.

Definition at line 207 of file glcommon2d.h.

virtual void CS::PluginCommon::GL::Graphics2DCommon::DrawBox ( int  x,
int  y,
int  w,
int  h,
int  color 
) [virtual]

Draw a box.

Implements iGraphics2D.

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

Draw a box in camera space.

Implements iGraphics2D.

virtual void CS::PluginCommon::GL::Graphics2DCommon::DrawLine ( float  x1,
float  y1,
float  x2,
float  y2,
int  color 
) [virtual]

Draw a line.

Implements iGraphics2D.

bool CS::PluginCommon::GL::Graphics2DCommon::DrawLineNearClip ( csVector3 v1,
csVector3 v2 
) [protected]

Clip line to be drawn by DrawLine to SMALL_Z.

Returns false if the line should not be drawn.

virtual void CS::PluginCommon::GL::Graphics2DCommon::DrawLineProjected ( const csVector3 v1,
const csVector3 v2,
const CS::Math::Matrix4 projection,
int  color 
) [virtual]

Draw a line in camera space.

Implements iGraphics2D.

virtual void CS::PluginCommon::GL::Graphics2DCommon::DrawLineProjected ( const csVector3 v1,
const csVector3 v2,
float  fov,
float  aspect,
int  color 
) [virtual]

Draw a line in camera space.

Implements iGraphics2D.

virtual void CS::PluginCommon::GL::Graphics2DCommon::DrawLineProjected ( const csVector3 v1,
const csVector3 v2,
float  viewHeight,
int  color 
) [virtual]

Draw a line in camera space.

Implements iGraphics2D.

virtual void CS::PluginCommon::GL::Graphics2DCommon::DrawPixel ( int  x,
int  y,
int  color 
) [virtual]

Draw a pixel.

Implements iGraphics2D.

virtual void CS::PluginCommon::GL::Graphics2DCommon::DrawPixels ( csPixelCoord const *  pixels,
int  num_pixels,
int  color 
) [virtual]

Draw a series of pixels.

Implements iGraphics2D.

virtual void CS::PluginCommon::GL::Graphics2DCommon::FinishDraw (  )  [virtual]

This routine should be called when you finished drawing.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

virtual bool CS::PluginCommon::GL::Graphics2DCommon::GetDoubleBufferState (  )  [inline, virtual]

Get the double buffer state.

Definition at line 204 of file glcommon2d.h.

virtual const char* CS::PluginCommon::GL::Graphics2DCommon::GetHWGLVersion (  )  [virtual]

Get a string containing the OpenGL version.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

virtual const char* CS::PluginCommon::GL::Graphics2DCommon::GetHWRenderer (  )  [virtual]

Get a string containing the hardware renderer.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

virtual const char* CS::PluginCommon::GL::Graphics2DCommon::GetHWVendor (  )  [virtual]

Get a string containing the vendor info.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

virtual void CS::PluginCommon::GL::Graphics2DCommon::GetPixel ( int  x,
int  y,
uint8 &  oR,
uint8 &  oG,
uint8 &  oB,
uint8 &  oA 
) [virtual]

As GetPixel() above, but with alpha.

Implements iGraphics2D.

virtual void CS::PluginCommon::GL::Graphics2DCommon::GetPixel ( int  x,
int  y,
uint8 &  oR,
uint8 &  oG,
uint8 &  oB 
) [virtual]

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

Implements iGraphics2D.

virtual bool CS::PluginCommon::GL::Graphics2DCommon::Initialize ( iObjectRegistry object_reg  )  [virtual]

Initialize the plugin.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

Reimplemented in csGraphics2DGLCommon.

virtual bool CS::PluginCommon::GL::Graphics2DCommon::Open (  )  [virtual]

Initialize font cache, texture cache, prints renderer name and version.

you should still print out the 2D driver type (X, Win, etc.) in your subclass code.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

void CS::PluginCommon::GL::Graphics2DCommon::OpenDriverDB ( const char *  phase = 0  )  [protected]

Open default driver database.

virtual bool CS::PluginCommon::GL::Graphics2DCommon::PerformExtensionV ( char const *  command,
va_list   
) [virtual]

Perform extension commands.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

void CS::PluginCommon::GL::Graphics2DCommon::ReadDatabase ( iDocumentNode dbRoot,
int  configPriority = iConfigManager::ConfigPriorityPlugin+20,
const char *  phase = 0 
) [inline]

Read a custom driver database.

Parameters:
dbRoot Document node containing the <configs> and <rules> nodes required by the driver DB as children.
configPriority Priority with which the individual tweaks are added to the configuration manager.
phase Simple rule filter; only rules whose "phase" attribute match this string are considered. 0 and an empty string are equivalent.

Reimplemented from iOpenGLDriverDatabase.

Definition at line 220 of file glcommon2d.h.

virtual bool CS::PluginCommon::GL::Graphics2DCommon::Resize ( int  width,
int  height 
) [virtual]

Resize the canvas.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

virtual bool CS::PluginCommon::GL::Graphics2DCommon::ScreenShot ( unsigned char *  buffer  )  [virtual]

Do a screenshot in preallocated buffer, return success or failure.

Implements iGraphics2D.

virtual csPtr<iImage> CS::PluginCommon::GL::Graphics2DCommon::ScreenShot (  )  [virtual]

Do a screenshot: return a new iImage object.

Implements iGraphics2D.

virtual void CS::PluginCommon::GL::Graphics2DCommon::SetClipRect ( int  xmin,
int  ymin,
int  xmax,
int  ymax 
) [virtual]

Set clipping rectangle.

Reimplemented from CS::PluginCommon::Graphics2DCommon.

void CS::PluginCommon::GL::Graphics2DCommon::setGLColorfromint ( int  color  )  [protected]

Set up current GL RGB color from a packed color format.

void CS::PluginCommon::GL::Graphics2DCommon::SetViewport ( int  left,
int  top,
int  width,
int  height 
) [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.

Reimplemented from CS::PluginCommon::Graphics2DCommon.


Member Data Documentation

Driver database.

Definition at line 96 of file glcommon2d.h.

Extension manager.

Definition at line 90 of file glcommon2d.h.

Multisample samples.

Whether to favor quality or speed.

Definition at line 94 of file glcommon2d.h.

Cache for GL states.

Definition at line 72 of file glcommon2d.h.


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

Generated for Crystal Space 2.1 by doxygen 1.6.1