CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

csGraphics2DGLCommon Class Reference

Basic OpenGL version of the 2D driver class You can look at the openGLX graphics class as an example of how to inherit and use this class. More...

#include <csplugincommon/opengl/glcommon2d.h>

Inheritance diagram for csGraphics2DGLCommon:

csGraphics2D iEventPlug iGraphics2D iBase iBase List of all members.

Public Member Functions

 csGraphics2DGLCommon (iBase *iParent)
 Constructor does little, most initialization stuff happens in Initialize().
virtual ~csGraphics2DGLCommon ()
 Clear font cache etc.
virtual bool Initialize (iObjectRegistry *object_reg)
 Initialize the plugin.
virtual bool Open ()
 Initialize font cache, texture cache, prints renderer name and version.
virtual void Close ()
 (*) Close graphics system
virtual void SetClipRect (int xmin, int ymin, int xmax, int ymax)
 Set clipping rectangle.
virtual bool BeginDraw ()
 This routine should be called before any draw operations.
virtual void FinishDraw ()
 This routine should be called when you finished drawing.
virtual bool Resize (int width, int height)
 Resize the canvas.
virtual void Clear (int color)
 Clear the screen with color.
virtual void SetRGB (int i, int r, int g, int b)
 Set a palette entry.
virtual int FindRGB (int r, int g, int b, int a=255)
 Find an RGB (0..255) color.
virtual void GetRGB (int color, int &r, int &g, int &b)
 Retrieve the R,G,B tuple for a given color index.
virtual void GetRGB (int color, int &r, int &g, int &b, int &a)
 Retrieve the R,G,B,A tuple for a given color index.
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.
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 Blit (int x, int y, int w, int h, unsigned char const *data)
 Blit.
virtual unsigned char * GetPixelAt (int x, int y)
 Get address of video RAM at given x,y coordinates.
virtual csPtr< iImageScreenShot ()
 Do a screenshot: return a new iImage object.
virtual csImageAreaSaveArea (int x, int y, int w, int h)
 Save a subarea of screen area into the variable Data.
virtual void RestoreArea (csImageArea *Area, bool Free=true)
 Restore a subarea of screen saved with SaveArea().
virtual bool GetDoubleBufferState ()
 Get the double buffer state.
virtual bool DoubleBuffer (bool Enable)
 Enable or disable double buffering; returns success status.
virtual bool PerformExtensionV (char const *command, va_list)
 Perform extension commands.
virtual bool DebugCommand (const char *cmd)
 Execute a debug command.
virtual unsigned GetPotentiallyConflictingEvents ()
 Get the mask of events that can be generated by this source and are generated directly from user actions (e.g.
virtual unsigned QueryEventPriority (unsigned)
 Query how strong the plug's wish to generate certain class of events is.

Public Attributes

csRef< iEventOutletEventOutlet
 The event plug object.

Protected Member Functions

void DecomposeColor (int iColor, GLubyte &oR, GLubyte &oG, GLubyte &oB, GLubyte &oA)
 Decompose a color ID into r,g,b components.
void DecomposeColor (int iColor, float &oR, float &oG, float &oB, float &oA)
 Same but uses floating-point format.
void setGLColorfromint (int color)
 Set up current GL RGB color from a packed color format.

Protected Attributes

csGLStateCachestatecache
 Cache for GL states.
csGLExtensionManager ext
 Extension manager.
bool multiFavorQuality
 Whether to favor quality or speed.
GLPixelFormat currentFormat
 Depth buffer resolution.
csGLDriverDatabase driverdb
 Driver database.

Detailed Description

Basic OpenGL version of the 2D driver class You can look at the openGLX graphics class 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. -GJH

Definition at line 52 of file glcommon2d.h.


Constructor & Destructor Documentation

csGraphics2DGLCommon::csGraphics2DGLCommon iBase iParent  ) 
 

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

virtual csGraphics2DGLCommon::~csGraphics2DGLCommon  )  [virtual]
 

Clear font cache etc.


Member Function Documentation

virtual bool csGraphics2DGLCommon::BeginDraw  )  [virtual]
 

This routine should be called before any draw operations.

It should return true if graphics context is ready.

Reimplemented from csGraphics2D.

virtual void csGraphics2DGLCommon::Blit int  x,
int  y,
int  w,
int  h,
unsigned char const *  data
[virtual]
 

Blit.

Reimplemented from csGraphics2D.

virtual void csGraphics2DGLCommon::Clear int  color  )  [virtual]
 

Clear the screen with color.

Reimplemented from csGraphics2D.

virtual void csGraphics2DGLCommon::Close  )  [virtual]
 

(*) Close graphics system

Reimplemented from csGraphics2D.

virtual bool csGraphics2DGLCommon::DebugCommand const char *  cmd  )  [virtual]
 

Execute a debug command.

Reimplemented from csGraphics2D.

void csGraphics2DGLCommon::DecomposeColor int  iColor,
float &  oR,
float &  oG,
float &  oB,
float &  oA
[protected]
 

Same but uses floating-point format.

void csGraphics2DGLCommon::DecomposeColor int  iColor,
GLubyte &  oR,
GLubyte &  oG,
GLubyte &  oB,
GLubyte &  oA
[protected]
 

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

virtual bool csGraphics2DGLCommon::DoubleBuffer bool  Enable  )  [inline, virtual]
 

Enable or disable double buffering; returns success status.

Reimplemented from csGraphics2D.

Definition at line 255 of file glcommon2d.h.

virtual void csGraphics2DGLCommon::DrawBox int  x,
int  y,
int  w,
int  h,
int  color
[virtual]
 

Draw a box.

Reimplemented from csGraphics2D.

virtual void csGraphics2DGLCommon::DrawLine float  x1,
float  y1,
float  x2,
float  y2,
int  color
[virtual]
 

Draw a line.

Reimplemented from csGraphics2D.

virtual void csGraphics2DGLCommon::DrawPixel int  x,
int  y,
int  color
[virtual]
 

Draw a pixel.

Reimplemented from csGraphics2D.

virtual void csGraphics2DGLCommon::DrawPixels csPixelCoord const *  pixels,
int  num_pixels,
int  color
[virtual]
 

Draw a series of pixels.

Reimplemented from csGraphics2D.

virtual int csGraphics2DGLCommon::FindRGB int  r,
int  g,
int  b,
int  a = 255
[inline, virtual]
 

Find an RGB (0..255) color.

If there is a palette, this returns an entry index set with SetRGB(). If the returned value is -1, a suitable palette entry was not found. Without a palette, the actual color bytes are returned.

Use returned value for color arguments in iGraphics2D.

Reimplemented from csGraphics2D.

Definition at line 196 of file glcommon2d.h.

virtual void csGraphics2DGLCommon::FinishDraw  )  [virtual]
 

This routine should be called when you finished drawing.

Reimplemented from csGraphics2D.

virtual bool csGraphics2DGLCommon::GetDoubleBufferState  )  [inline, virtual]
 

Get the double buffer state.

Reimplemented from csGraphics2D.

Definition at line 252 of file glcommon2d.h.

virtual unsigned char* csGraphics2DGLCommon::GetPixelAt int  x,
int  y
[virtual]
 

Get address of video RAM at given x,y coordinates.

The OpenGL version of this function just returns 0 if not doing a screenshot.

Reimplemented from csGraphics2D.

virtual unsigned csGraphics2DGLCommon::GetPotentiallyConflictingEvents  )  [inline, virtual]
 

Get the mask of events that can be generated by this source and are generated directly from user actions (e.g.

key presses, mouse clicks and so on). This is used to locate potentialy conflicting combinations of event source plugins (for example two event sources may generate a csevKeyDown event each from every key press).

The mask is a combination of CSEVTYPE_XXX values ORed together.

Implements iEventPlug.

Definition at line 266 of file glcommon2d.h.

References CSEVTYPE_Keyboard.

virtual void csGraphics2DGLCommon::GetRGB int  color,
int &  r,
int &  g,
int &  b,
int &  a
[inline, virtual]
 

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

Reimplemented from csGraphics2D.

Definition at line 214 of file glcommon2d.h.

References csGraphics2D::GetRGB().

virtual void csGraphics2DGLCommon::GetRGB int  color,
int &  r,
int &  g,
int &  b
[inline, virtual]
 

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

Reimplemented from csGraphics2D.

Definition at line 208 of file glcommon2d.h.

virtual bool csGraphics2DGLCommon::Initialize iObjectRegistry object_reg  )  [virtual]
 

Initialize the plugin.

Reimplemented from csGraphics2D.

virtual bool csGraphics2DGLCommon::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 csGraphics2D.

virtual bool csGraphics2DGLCommon::PerformExtensionV char const *  command,
va_list 
[virtual]
 

Perform extension commands.

Reimplemented from csGraphics2D.

virtual unsigned csGraphics2DGLCommon::QueryEventPriority unsigned   )  [inline, virtual]
 

Query how strong the plug's wish to generate certain class of events is.

The plug with the strongest wish wins. The argument is one of CSEVTYPE_XXX values (but never a combination of several OR'ed together).

The typical value is somewhere around 100; the event plugs which are sometimes implemented inside the system drivers (such as for Windows and DJGPP) usually have the priority 100.

Implements iEventPlug.

Definition at line 268 of file glcommon2d.h.

virtual bool csGraphics2DGLCommon::Resize int  width,
int  height
[virtual]
 

Resize the canvas.

Reimplemented from csGraphics2D.

virtual void csGraphics2DGLCommon::RestoreArea csImageArea Area,
bool  Free = true
[virtual]
 

Restore a subarea of screen saved with SaveArea().

Reimplemented from csGraphics2D.

virtual csImageArea* csGraphics2DGLCommon::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.

Reimplemented from csGraphics2D.

virtual csPtr<iImage> csGraphics2DGLCommon::ScreenShot  )  [virtual]
 

Do a screenshot: return a new iImage object.

Reimplemented from csGraphics2D.

virtual void csGraphics2DGLCommon::SetClipRect int  xmin,
int  ymin,
int  xmax,
int  ymax
[virtual]
 

Set clipping rectangle.

Reimplemented from csGraphics2D.

void csGraphics2DGLCommon::setGLColorfromint int  color  )  [protected]
 

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

virtual void csGraphics2DGLCommon::SetRGB int  i,
int  r,
int  g,
int  b
[virtual]
 

Set a palette entry.

Reimplemented from csGraphics2D.


Member Data Documentation

GLPixelFormat csGraphics2DGLCommon::currentFormat [protected]
 

Depth buffer resolution.

Definition at line 128 of file glcommon2d.h.

csGLDriverDatabase csGraphics2DGLCommon::driverdb [protected]
 

Driver database.

Definition at line 130 of file glcommon2d.h.

csRef<iEventOutlet> csGraphics2DGLCommon::EventOutlet
 

The event plug object.

Definition at line 141 of file glcommon2d.h.

csGLExtensionManager csGraphics2DGLCommon::ext [protected]
 

Extension manager.

Definition at line 121 of file glcommon2d.h.

bool csGraphics2DGLCommon::multiFavorQuality [protected]
 

Whether to favor quality or speed.

Definition at line 125 of file glcommon2d.h.

csGLStateCache* csGraphics2DGLCommon::statecache [protected]
 

Cache for GL states.

Definition at line 101 of file glcommon2d.h.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.3.9.1