An interface for all Renderers. More...
#include <AbstractRenderer.h>
Inherited by D3DRenderer.
Public Member Functions | |
virtual | ~AbstractRenderer () |
Destructor. | |
virtual void | BeginRendering ()=0 |
Can be implemented to begin rendering the scene, this may include doing things like clearing the back buffer, setting up any global transforms etc etc. | |
virtual void | EndRendering ()=0 |
Can be implemented to finalize rendering, this may include presenting the display by flipping the buffers. | |
virtual void | SetClearColour (const Colour &c)=0 |
Sets the clear colour, the clear colour is the colour that the backbuffer should be cleared to upon each call to BeginRendering(). | |
virtual void | DrawLines (const LineVertex *pVertices, const int nNumPoints, const int nWidth, const float fTranslateX, const float fTranslateY, const float fRotation)=0 |
Can be used to draw basic lines to the screen. | |
virtual void | DrawSprite (const Sprite *pSprite, ResourceCache *const pResourceCache, const Vector2 &position, const Vector2 ¢er, const float fRotation, const float fScaleX, const float fScaleY)=0 |
Used to draw sprites, or two-dimensional images to the screen. | |
virtual void | DrawString (const std::wstring &text, const std::string &font, const int nSize, const Vector2 &position, const int nAlignment, const Colour &c, bool bBold, bool bItalic)=0 |
Used to draw a single line of text to the screen. | |
virtual void | DrawText (const std::wstring &text, const std::string &font, const int nSize, const Rect &rect, const int nAlignment, Colour &c, bool bBold, bool bItalic)=0 |
Used to draw multiple lines of text to the screen. | |
virtual void | DrawModel (const PTModel &model, const Vector2 &translation, const float fRotation, const float fScale)=0 |
Used to draw a model to the screen. | |
virtual bool | CanRender ()=0 |
Used by the engine to determine whether rendering can be done, if this function returns false then the engine will pause the game until it returns true. | |
virtual std::pair< int, int > | GetResolution ()=0 |
Used be the engine to determine the current screen resolution. | |
virtual void | ClearArea (const Rect &rect, const Colour &c)=0 |
Can be used to clear a specific area on the backbuffer. | |
virtual int | GetStringWidth (const std::wstring &textString, const std::string &font, const int nFontHeight, bool bBold, bool bItalic)=0 |
A helper function which asks the renderer how long a string will be (in pixels) when it it is drawn to the screen. |
An interface for all Renderers.
This interface should be used when a custom renderer needs to be created, i.e. for a specific type of platform. Everything that renders interacts directly with this interface and it is up to users in order to provide the correct implementation of each of the given methods. The methods provided by this include defining draw functions that entities/UI can use, and other useful functions that the renderer should provide like preparing the scene for rendering or finalizing the scene.
virtual bool AbstractRenderer::CanRender | ( | ) | [pure virtual] |
Used by the engine to determine whether rendering can be done, if this function returns false then the engine will pause the game until it returns true.
Implemented in D3DRenderer.
Can be used to clear a specific area on the backbuffer.
rect | The rectangular area to clear. | |
c | The colour to clear it to. |
Implemented in D3DRenderer.
virtual void AbstractRenderer::DrawLines | ( | const LineVertex * | pVertices, | |
const int | nNumPoints, | |||
const int | nWidth, | |||
const float | fTranslateX, | |||
const float | fTranslateY, | |||
const float | fRotation | |||
) | [pure virtual] |
Can be used to draw basic lines to the screen.
pVertices | A pointer to an array or vertices that represent the line. | |
nNumPoints | The number of vertices in the pVertices array. | |
nWidth | The width of the line. | |
fTranslateX | How to translate the points provided in the pVertices buffer in the x-direction. | |
fTranslateY | How to translate the points provides in the pVertices buffer in the y-direction. | |
fRotation | How to rotate the points provided in the pVertices buffer in radians. |
Implemented in D3DRenderer.
virtual void AbstractRenderer::DrawModel | ( | const PTModel & | model, | |
const Vector2 & | translation, | |||
const float | fRotation, | |||
const float | fScale | |||
) | [pure virtual] |
Used to draw a model to the screen.
[i]Note: Models passed into this function should be constructed of triangles.[/i]
model | A reference to the model to be drawn. | |
translation | The position of the model (in pixels). | |
fRotation | How to rotate the model, in radians. | |
fScale | How much overall scaling to put onto the model, this should be 1 for no scaling. |
Implemented in D3DRenderer.
virtual void AbstractRenderer::DrawSprite | ( | const Sprite * | pSprite, | |
ResourceCache *const | pResourceCache, | |||
const Vector2 & | position, | |||
const Vector2 & | center, | |||
const float | fRotation, | |||
const float | fScaleX, | |||
const float | fScaleY | |||
) | [pure virtual] |
Used to draw sprites, or two-dimensional images to the screen.
pSprite | A pointer to a sprite structure which contains details of the sprite to draw. | |
pResourceCache | A pointer to the resource cache from which the image data will be loaded. | |
position | The position on screen (in pixels) at which to draw the sprite. | |
center | The center of the sprite, this point on the sprite will be placed at position and rotated about here. | |
fRotation | How much to rotate the sprite about center. | |
fScaleX | How much to scale the sprite in the x-direction. | |
fScaleY | How much to scale the sprite in the y-direction. |
Implemented in D3DRenderer.
virtual void AbstractRenderer::DrawString | ( | const std::wstring & | text, | |
const std::string & | font, | |||
const int | nSize, | |||
const Vector2 & | position, | |||
const int | nAlignment, | |||
const Colour & | c, | |||
bool | bBold, | |||
bool | bItalic | |||
) | [pure virtual] |
Used to draw a single line of text to the screen.
text | The string to draw. | |
font | The font to draw the text int. | |
nSize | The height of the text to draw. | |
position | The position on screen which to draw the text (in pixels). | |
nAlignment | The alignment of the text can be a combinatation of the TEXTALIGNMENT enumeration. | |
c | The colour of the text to draw. | |
bBold | Whether the text should be drawn in bold. | |
bItalic | Whether the text should be drawn in italics. |
Implemented in D3DRenderer.
virtual void AbstractRenderer::DrawText | ( | const std::wstring & | text, | |
const std::string & | font, | |||
const int | nSize, | |||
const Rect & | rect, | |||
const int | nAlignment, | |||
Colour & | c, | |||
bool | bBold, | |||
bool | bItalic | |||
) | [pure virtual] |
Used to draw multiple lines of text to the screen.
text | The string to draw. | |
font | The font to draw the text int. | |
nSize | The height of the text to draw. | |
rect | The rectangle which to fit the text into, wrapping will be done when the text touches the edges of this rect. | |
nAlignment | The alignment of the text can be a combinatation of the TEXTALIGNMENT enumeration. | |
c | The colour of the text to draw. | |
bBold | Whether the text should be drawn in bold. | |
bItalic | Whether the text should be drawn in italics. |
Implemented in D3DRenderer.
virtual std::pair<int, int> AbstractRenderer::GetResolution | ( | ) | [pure virtual] |
Used be the engine to determine the current screen resolution.
Implemented in D3DRenderer.
virtual int AbstractRenderer::GetStringWidth | ( | const std::wstring & | textString, | |
const std::string & | font, | |||
const int | nFontHeight, | |||
bool | bBold, | |||
bool | bItalic | |||
) | [pure virtual] |
A helper function which asks the renderer how long a string will be (in pixels) when it it is drawn to the screen.
textString | The text to check. | |
font | The font name of the text. | |
nFontHeight | The height of the font to check. | |
bBold | Whether the calculation should be done for bold text. | |
bItalic | Whether the calculation should be done for italic text. |
Implemented in D3DRenderer.
virtual void AbstractRenderer::SetClearColour | ( | const Colour & | c | ) | [pure virtual] |
Sets the clear colour, the clear colour is the colour that the backbuffer should be cleared to upon each call to BeginRendering().
c | The colour to clear to. |
Implemented in D3DRenderer.