FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
FIFE::RenderBackend Class Referenceabstract

#include <renderbackend.h>

Inheritance diagram for FIFE::RenderBackend:
Inheritance graph
Collaboration diagram for FIFE::RenderBackend:
Collaboration graph

Public Member Functions

 RenderBackend (const SDL_Color &colorkey)
 
virtual ~RenderBackend ()
 
virtual const std::string & getName () const =0
 
virtual void startFrame ()
 
virtual void endFrame ()
 
virtual void init (const std::string &driver)=0
 
virtual void clearBackBuffer ()=0
 
virtual void setLightingModel (uint32_t lighting)=0
 
virtual uint32_t getLightingModel () const =0
 
virtual void setLighting (float red, float green, float blue)=0
 
virtual void resetLighting ()=0
 
virtual void resetStencilBuffer (uint8_t buffer)=0
 
virtual void changeBlending (int32_t scr, int32_t dst)=0
 
void deinit ()
 
virtual void createMainScreen (const ScreenMode &mode, const std::string &title, const std::string &icon)=0
 
virtual void setScreenMode (const ScreenMode &mode)=0
 
virtual ImagecreateImage (const uint8_t *data, uint32_t width, uint32_t height)=0
 
virtual ImagecreateImage (SDL_Surface *surface)=0
 
virtual void renderVertexArrays ()=0
 
virtual void addImageToArray (uint32_t id, const Rect &rec, float const *st, uint8_t alpha, uint8_t const *rgb)=0
 
virtual void changeRenderInfos (uint16_t elements, int32_t src, int32_t dst, bool light, bool stentest, uint8_t stenref, GLConstants stenop, GLConstants stenfunc)=0
 
virtual void captureScreen (const std::string &filename)=0
 
virtual void captureScreen (const std::string &filename, uint32_t width, uint32_t height)=0
 
const ScreenMode & getCurrentScreenMode () const
 
void pushClipArea (const Rect &cliparea, bool clear=true)
 
void popClipArea ()
 
const RectgetClipArea () const
 
virtual bool putPixel (int32_t x, int32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
 
virtual void drawLine (const Point &p1, const Point &p2, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
 
virtual void drawTriangle (const Point &p1, const Point &p2, const Point &p3, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
 
virtual void drawRectangle (const Point &p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
 
virtual void fillRectangle (const Point &p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
 
virtual void drawQuad (const Point &p1, const Point &p2, const Point &p3, const Point &p4, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
 
virtual void drawVertex (const Point &p, const uint8_t size, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
 
virtual void drawLightPrimitive (const Point &p, uint8_t intensity, float radius, int32_t subdivisions, float xstretch, float ystretch, uint8_t red, uint8_t green, uint8_t blue)=0
 
void setAlphaOptimizerEnabled (bool enabled)
 
bool isAlphaOptimizerEnabled () const
 
void setImageCompressingEnabled (bool enabled)
 
bool isImageCompressingEnabled () const
 
void setFramebufferEnabled (bool enabled)
 
bool isFramebufferEnabled () const
 
void setNPOTEnabled (bool enabled)
 
bool isNPOTEnabled () const
 
void setColorKeyEnabled (bool colorkeyenable)
 
bool isColorKeyEnabled () const
 
void setColorKey (const SDL_Color &colorkey)
 
const SDL_Color & getColorKey () const
 
void setBackgroundColor (uint8_t r, uint8_t g, uint8_t b)
 
void resetBackgroundColor ()
 
const SDL_PixelFormat & getPixelFormat () const
 
void setFrameLimitEnabled (bool limited)
 
bool isFrameLimitEnabled () const
 
void setFrameLimit (uint16_t framelimit)
 
uint16_t getFrameLimit () const
 
SDL_Surface * getRenderTargetSurface ()
 
virtual void attachRenderTarget (ImagePtr &img, bool discard)=0
 
virtual void detachRenderTarget ()=0
 

Protected Member Functions

virtual void setClipArea (const Rect &cliparea, bool clear)=0
 
void clearClipArea ()
 

Detailed Description

Abstract interface for all the renderbackends.

Definition at line 92 of file renderbackend.h.

Constructor & Destructor Documentation

FIFE::RenderBackend::RenderBackend ( const SDL_Color &  colorkey)

Constructor.

Parameters
nameThe name of the new renderbackend.

Definition at line 34 of file renderbackend.cpp.

FIFE::RenderBackend::~RenderBackend ( )
virtual

Destructor.

Definition at line 52 of file renderbackend.cpp.

Member Function Documentation

virtual void FIFE::RenderBackend::addImageToArray ( uint32_t  id,
const Rect rec,
float const *  st,
uint8_t  alpha,
uint8_t const *  rgb 
)
pure virtual

Add the Image data to the array

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::GLImage::render().

Here is the caller graph for this function:

virtual void FIFE::RenderBackend::attachRenderTarget ( ImagePtr img,
bool  discard 
)
pure virtual

Attaches given image as a new render surface

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

virtual void FIFE::RenderBackend::captureScreen ( const std::string &  filename)
pure virtual

Creates a Screenshot and saves it to a file.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

virtual void FIFE::RenderBackend::captureScreen ( const std::string &  filename,
uint32_t  width,
uint32_t  height 
)
pure virtual

Creates a Screenshot with the given size(w,h) and saves it to a file.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

virtual void FIFE::RenderBackend::changeBlending ( int32_t  scr,
int32_t  dst 
)
pure virtual

Change the Blendingmodel.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

virtual void FIFE::RenderBackend::changeRenderInfos ( uint16_t  elements,
int32_t  src,
int32_t  dst,
bool  light,
bool  stentest,
uint8_t  stenref,
GLConstants  stenop,
GLConstants  stenfunc 
)
pure virtual

Dirty helper function to change the render infos

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

virtual void FIFE::RenderBackend::clearBackBuffer ( )
pure virtual

Forces a clear of the backbuffer

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Engine::pump().

Here is the caller graph for this function:

void FIFE::RenderBackend::clearClipArea ( )
protected

Clears any possible clip areas

See Also
pushClipArea

Definition at line 122 of file renderbackend.cpp.

References setClipArea().

virtual Image* FIFE::RenderBackend::createImage ( const uint8_t *  data,
uint32_t  width,
uint32_t  height 
)
pure virtual

Creates an Image suitable for this renderbackend.

Parameters
dataPointer to the imagedata (needs to be in RGBA, 8 bits per channel).
widthWidth of the image.
heightHeight of the image.
Returns
The new Image.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

virtual Image* FIFE::RenderBackend::createImage ( SDL_Surface *  surface)
pure virtual

Helper function to create images from SDL_Surfaces. Takes ownership over the surface.

Parameters
surfaceThe surface to convert.
Returns
The new Image.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

virtual void FIFE::RenderBackend::createMainScreen ( const ScreenMode &  mode,
const std::string &  title,
const std::string &  icon 
)
pure virtual

Creates the mainscreen (the display window).

Parameters
modeThe ScreenMode to use.
See Also
FIFE::ScreenMode.
Parameters
titeThe window title to use.
iconThe window icon to use.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Engine::init().

Here is the caller graph for this function:

void FIFE::RenderBackend::deinit ( )

Performs cleanup actions.

Definition at line 55 of file renderbackend.cpp.

virtual void FIFE::RenderBackend::detachRenderTarget ( )
pure virtual

Detaches current render surface

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

virtual void FIFE::RenderBackend::drawLightPrimitive ( const Point p,
uint8_t  intensity,
float  radius,
int32_t  subdivisions,
float  xstretch,
float  ystretch,
uint8_t  red,
uint8_t  green,
uint8_t  blue 
)
pure virtual

Draws a light primitive that based on a triangle fan

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

virtual void FIFE::RenderBackend::drawLine ( const Point p1,
const Point p2,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
pure virtual

Draws line between given points with given RGBA

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

Referenced by FIFE::CellSelectionRenderer::render().

Here is the caller graph for this function:

virtual void FIFE::RenderBackend::drawQuad ( const Point p1,
const Point p2,
const Point p3,
const Point p4,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
pure virtual

Draws quad between given points with given RGBA

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

virtual void FIFE::RenderBackend::drawRectangle ( const Point p,
uint16_t  w,
uint16_t  h,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
pure virtual

Draws an axis parallel rectangle.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

virtual void FIFE::RenderBackend::drawTriangle ( const Point p1,
const Point p2,
const Point p3,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
pure virtual

Draws triangle between given points with given RGBA

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

virtual void FIFE::RenderBackend::drawVertex ( const Point p,
const uint8_t  size,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
pure virtual

Draws a quad that represents a vertex with given RGBA

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

void FIFE::RenderBackend::endFrame ( )
virtual

Called when a frame is finished and ready to be displayed.

Reimplemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Definition at line 68 of file renderbackend.cpp.

Referenced by FIFE::RenderBackendOpenGLe::endFrame(), FIFE::RenderBackendSDL::endFrame(), FIFE::RenderBackendOpenGL::endFrame(), and FIFE::Engine::pump().

Here is the caller graph for this function:

virtual void FIFE::RenderBackend::fillRectangle ( const Point p,
uint16_t  w,
uint16_t  h,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
pure virtual

Draws a filled axis parallel rectangle.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

const Rect & FIFE::RenderBackend::getClipArea ( ) const

Gets the current clip area

See Also
pushClipArea

Definition at line 114 of file renderbackend.cpp.

const SDL_Color & FIFE::RenderBackend::getColorKey ( ) const

Gets the global colorkey setting

Definition at line 139 of file renderbackend.cpp.

const ScreenMode & FIFE::RenderBackend::getCurrentScreenMode ( ) const

Get current screen mode

Returns
The current screen mode

Definition at line 78 of file renderbackend.cpp.

uint16_t FIFE::RenderBackend::getFrameLimit ( ) const

Gets the frame limit

Definition at line 172 of file renderbackend.cpp.

virtual uint32_t FIFE::RenderBackend::getLightingModel ( ) const
pure virtual

Gets the current light model.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Camera::render().

Here is the caller graph for this function:

virtual const std::string& FIFE::RenderBackend::getName ( ) const
pure virtual

The name of the renderbackend.

Returns
The name of this renderbackend.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Camera::render().

Here is the caller graph for this function:

const SDL_PixelFormat & FIFE::RenderBackend::getPixelFormat ( ) const

Gets the current screen rgba format

Definition at line 156 of file renderbackend.cpp.

SDL_Surface * FIFE::RenderBackend::getRenderTargetSurface ( )

Returns currently attached render surface

Definition at line 176 of file renderbackend.cpp.

Referenced by FIFE::GLImage::render().

Here is the caller graph for this function:

virtual void FIFE::RenderBackend::init ( const std::string &  driver)
pure virtual

Initializes the backend.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Engine::init().

Here is the caller graph for this function:

bool FIFE::RenderBackend::isAlphaOptimizerEnabled ( ) const
inline
See Also
setAlphaOptimizerEnabled

Definition at line 273 of file renderbackend.h.

bool FIFE::RenderBackend::isColorKeyEnabled ( ) const

Gets whether the colorkey feature is in use

Definition at line 131 of file renderbackend.cpp.

bool FIFE::RenderBackend::isFramebufferEnabled ( ) const
inline
See Also
setFramebufferEnabled

Definition at line 290 of file renderbackend.h.

bool FIFE::RenderBackend::isFrameLimitEnabled ( ) const

Gets whether the frame limiter is in use

Definition at line 164 of file renderbackend.cpp.

bool FIFE::RenderBackend::isImageCompressingEnabled ( ) const
inline
See Also
setImageCompressingEnabled

Definition at line 282 of file renderbackend.h.

bool FIFE::RenderBackend::isNPOTEnabled ( ) const
inline
See Also
setNPOTEnabled

Definition at line 298 of file renderbackend.h.

void FIFE::RenderBackend::popClipArea ( )

Pops clip area from clip stack

See Also
pushClipArea

Definition at line 103 of file renderbackend.cpp.

References setClipArea().

Referenced by FIFE::Cursor::draw(), and FIFE::Camera::render().

Here is the caller graph for this function:

void FIFE::RenderBackend::pushClipArea ( const Rect cliparea,
bool  clear = true 
)

Pushes clip area to clip stack Clip areas define which area is drawn on screen. Usable e.g. with viewports note that previous items in stack do not affect the latest area pushed

Definition at line 95 of file renderbackend.cpp.

References setClipArea().

Referenced by FIFE::Cursor::draw(), and FIFE::Camera::render().

Here is the caller graph for this function:

virtual bool FIFE::RenderBackend::putPixel ( int32_t  x,
int32_t  y,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
pure virtual

Writes pixel to given position. Returns true, if pixel was written (not out of bounds)

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendOpenGLe, and FIFE::RenderBackendSDL.

virtual void FIFE::RenderBackend::renderVertexArrays ( )
pure virtual

Render the Vertex Arrays, only for primitives (points, lines,...)

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Cursor::draw(), and FIFE::Camera::render().

Here is the caller graph for this function:

void FIFE::RenderBackend::resetBackgroundColor ( )

Reset the background color to black

Definition at line 152 of file renderbackend.cpp.

References setBackgroundColor().

virtual void FIFE::RenderBackend::resetLighting ( )
pure virtual

Reset lighting with default values.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Camera::render(), and FIFE::Camera::resetLightingColor().

Here is the caller graph for this function:

virtual void FIFE::RenderBackend::resetStencilBuffer ( uint8_t  buffer)
pure virtual

Reset stencil buffer with given value.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Camera::render().

Here is the caller graph for this function:

void FIFE::RenderBackend::setAlphaOptimizerEnabled ( bool  enabled)
inline

Enable or disable the alpha 'optimizing' code

Parameters
optimizeWether the image shall be analysed for 'fake' alpha images. Only implemented by and useful for the SDL backend at the moment.

Definition at line 269 of file renderbackend.h.

void FIFE::RenderBackend::setBackgroundColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Set the background color

Definition at line 143 of file renderbackend.cpp.

Referenced by resetBackgroundColor().

Here is the caller graph for this function:

virtual void FIFE::RenderBackend::setClipArea ( const Rect cliparea,
bool  clear 
)
protectedpure virtual

Sets given clip area into image

See Also
pushClipArea

Implemented in FIFE::RenderBackendOpenGLe, FIFE::RenderBackendOpenGL, and FIFE::RenderBackendSDL.

Referenced by clearClipArea(), popClipArea(), and pushClipArea().

Here is the caller graph for this function:

void FIFE::RenderBackend::setColorKey ( const SDL_Color &  colorkey)

Sets the global colorkey to use for images

Definition at line 135 of file renderbackend.cpp.

void FIFE::RenderBackend::setColorKeyEnabled ( bool  colorkeyenable)

Sets whether to use the colorkey feature

Definition at line 127 of file renderbackend.cpp.

Referenced by FIFE::Engine::init().

Here is the caller graph for this function:

void FIFE::RenderBackend::setFramebufferEnabled ( bool  enabled)
inline

Enables or disable the usage of the framebuffer, if available

Definition at line 286 of file renderbackend.h.

Referenced by FIFE::Engine::init().

Here is the caller graph for this function:

void FIFE::RenderBackend::setFrameLimit ( uint16_t  framelimit)

Sets the frame limit

Definition at line 168 of file renderbackend.cpp.

Referenced by FIFE::Engine::init().

Here is the caller graph for this function:

void FIFE::RenderBackend::setFrameLimitEnabled ( bool  limited)

Sets whether to use the frame limiter

Definition at line 160 of file renderbackend.cpp.

Referenced by FIFE::Engine::init().

Here is the caller graph for this function:

void FIFE::RenderBackend::setImageCompressingEnabled ( bool  enabled)
inline

Enables or disable compressing images by video driver.

Remarks
This is relevant for in OpenGL renderbackend

Definition at line 278 of file renderbackend.h.

Referenced by FIFE::Engine::init().

Here is the caller graph for this function:

virtual void FIFE::RenderBackend::setLighting ( float  red,
float  green,
float  blue 
)
pure virtual

Set colors for lighting

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Camera::render().

Here is the caller graph for this function:

virtual void FIFE::RenderBackend::setLightingModel ( uint32_t  lighting)
pure virtual

Initializes the light.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Engine::init().

Here is the caller graph for this function:

void FIFE::RenderBackend::setNPOTEnabled ( bool  enabled)
inline

Enables or disable the usage of npot, if available

Definition at line 294 of file renderbackend.h.

Referenced by FIFE::Engine::init().

Here is the caller graph for this function:

virtual void FIFE::RenderBackend::setScreenMode ( const ScreenMode &  mode)
pure virtual

Sets the mainscreen display mode.

Parameters
modeThe ScreenMode to change the display to.
See Also
FIFE::ScreenMode.

Implemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Referenced by FIFE::Engine::changeScreenMode().

Here is the caller graph for this function:

void FIFE::RenderBackend::startFrame ( )
virtual

Called when a new frame starts.

Reimplemented in FIFE::RenderBackendOpenGL, FIFE::RenderBackendSDL, and FIFE::RenderBackendOpenGLe.

Definition at line 62 of file renderbackend.cpp.

Referenced by FIFE::Engine::pump(), FIFE::RenderBackendOpenGLe::startFrame(), FIFE::RenderBackendSDL::startFrame(), and FIFE::RenderBackendOpenGL::startFrame().

Here is the caller graph for this function:


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