SDLScreen Class Reference

Implementation of the IScreen interface using SDL. More...

#include <Graphics/SDLScreen.h>

Inherits IScreen.

List of all members.

Public Member Functions

 SDLScreen ()
 Constructor.
 SDLScreen (int w, int h, const Color4f &backGroundColor, const std::string &title, bool center=false)
 Constructs an SDLScreen.
virtual ~SDLScreen ()
 Deconstructor.
bool Set (int w, int h)
 Sets the size of the drawable area of the screen.
bool Set (int w, int h, const Color4f &backGroundColor, const std::string &title)
 Sets the parameters of the screen.
bool CenterScreen ()
 Centers the window on the desktop. NOTE: Only usable in windowed mode.
bool BeginFrame ()
 Sets the screen to a state where it can be drawn too.
bool EndFrame ()
 Stops the ability to draw to the screen and displays the current contents of the screen.
virtual int Width () const
 Gets the width of the drawable screen area.
virtual int Height () const
 Gets the height of the drawable screen area.
virtual Rectf GetRect () const
 Gets the Rect of the drawable screen area.
virtual bool SaveScreenshot (const std::string &fileName) const
 Saves an image of the current screens buffer.
virtual std::string GetWindowTitle () const
 Gets the title of the window that houses the screen.
virtual void NormToScreenCoords (float xin, float yin, float &x, float &y) const
 Converts normalized device coordinates to absolute screen coordinates.
virtual void ScreenToNormCoords (float xin, float yin, float &x, float &y) const
 Converts absolute screen coordinates to normalized device coordinates to.
virtual bool QueueText (FontRef f, const char *str, const Color4f &color, const Point2f &p)
 Queues text to be drawn a the end of the frame.
virtual bool QueueText (FontRef f, const char *str, const Color4f &color, Font::TextAlignment align, const Point2f &offset=Point2f(0.0f, 0.0f))
 Queues aligned text to be drawn a the end of the frame.
virtual bool BeginBlendMode (BlendMode mode)
 Sets the BlendMode all further draw calls Default is BLENDMODE_ALPHA. NOTE: BeginBlendMode/EndBlendMode cannot be nested.
virtual bool EndBlendMode ()
 Ends the BlendMode mode being used and reverts back to BLENDMODE_ALPHA.
virtual BlendMode GetBlendMode () const
 Gets the currently active blend mode.
virtual bool EnableDrawRegion (Recti area)
 Sets the screen area where all subsequent draw calls will be limited to.
virtual bool DisableDrawRegion ()
 Disables using the draw engine.
virtual Recti GetDrawRegion () const
 Gets the current draw region.
bool DrawQueuedText ()
 Draws the currently queued text. Called in EndFrame().
bool Clear (const Color4f &color)
 Clears the drawable area of the screen to the specified color. Called in BeginFrame().

Detailed Description

Implementation of the IScreen interface using SDL.


Constructor & Destructor Documentation

SDLScreen::SDLScreen ( int  w,
int  h,
const Color4f backGroundColor,
const std::string &  title,
bool  center = false 
)

Constructs an SDLScreen.

Parameters:
[in] w the width of the drawable area of the screen.
[in] h the height of the drawable area of the screen.
[in] backGroundColor the color of the drawable area of the screen.
[in] title the title of the window that houses the screen.
[in] center set to true to have the screen centered on the desktop. Defaults to false.

Member Function Documentation

bool SDLScreen::BeginBlendMode ( BlendMode  mode  )  [virtual]

Sets the BlendMode all further draw calls Default is BLENDMODE_ALPHA. NOTE: BeginBlendMode/EndBlendMode cannot be nested.

Parameters:
[in] mode the BlendMode to use.
Returns:
True if the BlendMode was successfully set. Returns false if the blend mode could not be set. This can occure if BeginBlendMode has already been called but EndBlendMode has not.

Implements IScreen.

bool SDLScreen::CenterScreen (  )  [virtual]

Centers the window on the desktop. NOTE: Only usable in windowed mode.

Returns:
true if the screen was centered, false otherwise.

NOTE: Currently only supported for WIN32.

Implements IScreen.

bool SDLScreen::Clear ( const Color4f color  ) 

Clears the drawable area of the screen to the specified color. Called in BeginFrame().

Parameters:
[in] color the color to clear the screen to.
bool SDLScreen::DisableDrawRegion (  )  [virtual]

Disables using the draw engine.

Returns:
true if the draw region was disabled, false otherwise.

Implements IScreen.

bool SDLScreen::EnableDrawRegion ( Recti  area  )  [virtual]

Sets the screen area where all subsequent draw calls will be limited to.

Parameters:
[in] area the screen rectangle.
Returns:
true if the draw region was created, false otherwise.

NOTE: This can be called without a matching call to DisableDrawRegion().

Implements IScreen.

bool SDLScreen::EndBlendMode (  )  [virtual]

Ends the BlendMode mode being used and reverts back to BLENDMODE_ALPHA.

Returns:
True the BlendMode has been set back to BLENDMODE_ALPHA, returns false if EndBlendMode is called without first calling BeginBlendMode.

Implements IScreen.

BlendMode SDLScreen::GetBlendMode (  )  const [virtual]

Gets the currently active blend mode.

Returns:
the active BlendMode.

Implements IScreen.

virtual Recti SDLScreen::GetDrawRegion (  )  const [inline, virtual]

Gets the current draw region.

Returns:
the draw region.

Implements IScreen.

Rectf SDLScreen::GetRect (  )  const [virtual]

Gets the Rect of the drawable screen area.

Returns:
The Rect of the drawable screen area.

Implements IScreen.

virtual std::string SDLScreen::GetWindowTitle (  )  const [inline, virtual]

Gets the title of the window that houses the screen.

Returns:
The title of the window that houses the screen.

Implements IScreen.

virtual int SDLScreen::Height (  )  const [inline, virtual]

Gets the height of the drawable screen area.

Returns:
The height of the drawable screen area.

Implements IScreen.

void SDLScreen::NormToScreenCoords ( float  xin,
float  yin,
float &  x,
float &  y 
) const [virtual]

Converts normalized device coordinates to absolute screen coordinates.

Parameters:
[in] xin the normalized device coordinate in x to be converted.
[in] yin the normalized device coordinate in y to be converted.
[out] x the converted value of xin.
[out] y the converted value of yin.
See also:
ScreenToNormCoords

In normalized device coordinates the top left corner of the screen is at position (-1,-1), the bottom right corner of the screen is at position (1,1), and the center of the screen is at position (0,0). In absolute screen coordinates the top left corner of the screen is at position (-width/2,-height/2), the bottom right corner of the screen is at position (width/2,height/2), and the center of the screen is at position (0,0).

Implements IScreen.

bool SDLScreen::QueueText ( FontRef  f,
const char *  str,
const Color4f color,
Font::TextAlignment  align,
const Point2f offset = Point2f(0.0f, 0.0f) 
) [virtual]

Queues aligned text to be drawn a the end of the frame.

Parameters:
[in] f the font used to draw the text.
[in] str the text to draw.
[in] color the color to draw str.
[in] align the text alignment to use when drawing str. The screen is used as the area to align to.
[in] offset the amount to offset the text. Assumed to be in normalized device coordinates. Defaults to (0,0).

Implements IScreen.

bool SDLScreen::QueueText ( FontRef  f,
const char *  str,
const Color4f color,
const Point2f p 
) [virtual]

Queues text to be drawn a the end of the frame.

Parameters:
[in] f the font used to draw the text.
[in] str the text to draw.
[in] color the color to draw str.
[in] p the position to draw str. Assumed to be in normalized device coordinates.

Implements IScreen.

bool SDLScreen::SaveScreenshot ( const std::string &  fileName  )  const [virtual]

Saves an image of the current screens buffer.

Parameters:
[in] fileName the name of the image file to save.
Returns:
True if the image was saved, false otherwise.

Implements IScreen.

void SDLScreen::ScreenToNormCoords ( float  xin,
float  yin,
float &  x,
float &  y 
) const [virtual]

Converts absolute screen coordinates to normalized device coordinates to.

Parameters:
[in] xin the absolute screen coordinate in x to be converted.
[in] yin the absolute screen coordinate in y to be converted.
[out] x the converted value of xin.
[out] y the converted value of yin.
See also:
NormToScreenCoords

In normalized device coordinates the top left corner of the screen is at position (-1,-1), the bottom right corner of the screen is at position (1,1), and the center of the screen is at position (0,0). In absolute screen coordinates the top left corner of the screen is at position (-width/2,-height/2), the bottom right corner of the screen is at position (width/2,height/2), and the center of the screen is at position (0,0).

Implements IScreen.

bool SDLScreen::Set ( int  w,
int  h,
const Color4f backGroundColor,
const std::string &  title 
)

Sets the parameters of the screen.

Parameters:
[in] w the width of the drawable area of the screen.
[in] h the height of the drawable area of the screen.
[in] backGroundColor the color of the drawable area of the screen.
[in] title the title of the window that houses the screen.
bool SDLScreen::Set ( int  w,
int  h 
)

Sets the size of the drawable area of the screen.

Parameters:
[in] w the width of the drawable area of the screen.
[in] h the height of the drawable area of the screen.
virtual int SDLScreen::Width (  )  const [inline, virtual]

Gets the width of the drawable screen area.

Returns:
The width of the drawable screen area.

Implements IScreen.


The documentation for this class was generated from the following files:
Generated on Mon Apr 5 19:08:06 2010 for BrickOut |ReDuX| by  doxygen 1.6.3