Implementation of the IScreen interface using SDL. More...
#include <Graphics/SDLScreen.h>
Inherits IScreen.
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(). |
Implementation of the IScreen interface using SDL.
SDLScreen::SDLScreen | ( | int | w, | |
int | h, | |||
const Color4f & | backGroundColor, | |||
const std::string & | title, | |||
bool | center = false | |||
) |
Constructs an SDLScreen.
[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. |
bool SDLScreen::BeginBlendMode | ( | BlendMode | mode | ) | [virtual] |
Sets the BlendMode all further draw calls Default is BLENDMODE_ALPHA. NOTE: BeginBlendMode/EndBlendMode cannot be nested.
[in] | mode | the BlendMode to use. |
Implements IScreen.
bool SDLScreen::CenterScreen | ( | ) | [virtual] |
Centers the window on the desktop. NOTE: Only usable in windowed mode.
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().
[in] | color | the color to clear the screen to. |
bool SDLScreen::DisableDrawRegion | ( | ) | [virtual] |
Disables using the draw engine.
Implements IScreen.
bool SDLScreen::EnableDrawRegion | ( | Recti | area | ) | [virtual] |
Sets the screen area where all subsequent draw calls will be limited to.
[in] | area | the screen rectangle. |
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.
Implements IScreen.
BlendMode SDLScreen::GetBlendMode | ( | ) | const [virtual] |
virtual Recti SDLScreen::GetDrawRegion | ( | ) | const [inline, virtual] |
Rectf SDLScreen::GetRect | ( | ) | const [virtual] |
Gets 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.
Implements IScreen.
virtual int SDLScreen::Height | ( | ) | const [inline, virtual] |
Gets 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.
[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. |
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.
[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.
[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.
[in] | fileName | the name of the image file to save. |
Implements IScreen.
void SDLScreen::ScreenToNormCoords | ( | float | xin, | |
float | yin, | |||
float & | x, | |||
float & | y | |||
) | const [virtual] |
Converts absolute screen coordinates to normalized device coordinates to.
[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. |
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.
[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.
[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.
Implements IScreen.