#include <sdlgraphics.hpp>
Inheritance diagram for gcn::SDLGraphics:

Definition at line 74 of file sdlgraphics.hpp.
Public Member Functions | |
| virtual void | _beginDraw () |
| Initializes drawing. | |
| virtual void | _endDraw () |
| Deinitializes drawing. | |
| virtual void | drawImage (const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height) |
| Draws a part of an image. | |
| virtual void | drawLine (int x1, int y1, int x2, int y2) |
| Ddraws a line. | |
| virtual void | drawPoint (int x, int y) |
| Draws a single point/pixel. | |
| virtual void | drawRectangle (const Rectangle &rectangle) |
| Draws a simple, non-filled, rectangle with a one pixel width. | |
| virtual void | drawSDLSurface (SDL_Surface *surface, SDL_Rect source, SDL_Rect destination) |
| Draws an SDL_Surface on the target surface. | |
| virtual void | fillRectangle (const Rectangle &rectangle) |
| Draws a filled rectangle. | |
| virtual const Color & | getColor () const |
| Gets the color to use when drawing. | |
| virtual SDL_Surface * | getTarget () const |
| Gets the target SDL_Surface. | |
| virtual void | popClipArea () |
| Removes the top most clip area from the stack. | |
| virtual bool | pushClipArea (Rectangle area) |
| Pushes a clip area onto the stack. | |
| SDLGraphics () | |
| Constructor. | |
| virtual void | setColor (const Color &color) |
| Sets the color to use when drawing. | |
| virtual void | setTarget (SDL_Surface *target) |
| Sets the target SDL_Surface to draw to. | |
Protected Member Functions | |
| virtual void | drawHLine (int x1, int y, int x2) |
| Draws a horizontal line. | |
| virtual void | drawVLine (int x, int y1, int y2) |
| Draws a vertical line. | |
Protected Attributes | |
| bool | mAlpha |
| Color | mColor |
| SDL_Surface * | mTarget |
| void gcn::SDLGraphics::_beginDraw | ( | ) | [virtual] |
Initializes drawing.
Called by the Gui when Gui::draw() is called. It is needed by some implementations of Graphics to perform preparations before drawing. An example of such an implementation is the OpenGLGraphics.
NOTE: You will never need to call this function yourself, unless you use a Graphics object outside of Guichan.
Reimplemented from gcn::Graphics.
Definition at line 83 of file sdlgraphics.cpp.
References gcn::Rectangle::height, mTarget, pushClipArea(), gcn::Rectangle::width, gcn::Rectangle::x, and gcn::Rectangle::y.
| void gcn::SDLGraphics::_endDraw | ( | ) | [virtual] |
Deinitializes drawing.
Called by the Gui when a Gui::draw() is done. done. It should reset any state changes made by _beginDraw().
NOTE: You will never need to call this function yourself, unless you use a Graphics object outside of Guichan.
Reimplemented from gcn::Graphics.
Definition at line 93 of file sdlgraphics.cpp.
References popClipArea().
| void gcn::SDLGraphics::drawHLine | ( | int | x1, | |
| int | y, | |||
| int | x2 | |||
| ) | [protected, virtual] |
Draws a horizontal line.
| x1 | the start coordinate of the line. | |
| y | the y coordinate of the line. | |
| x2 | the end coordinate of the line. |
Definition at line 256 of file sdlgraphics.cpp.
References gcn::Color::a, gcn::Color::b, gcn::Color::g, gcn::Rectangle::height, mAlpha, gcn::Graphics::mClipStack, mColor, mTarget, gcn::Color::r, gcn::SDLAlpha32(), gcn::Rectangle::width, gcn::Rectangle::x, gcn::ClipRectangle::xOffset, gcn::Rectangle::y, and gcn::ClipRectangle::yOffset.
Referenced by drawLine(), and drawRectangle().
| void gcn::SDLGraphics::drawImage | ( | const Image * | image, | |
| int | srcX, | |||
| int | srcY, | |||
| int | dstX, | |||
| int | dstY, | |||
| int | width, | |||
| int | height | |||
| ) | [virtual] |
Draws a part of an image.
NOTE: Width and height arguments will not scale the image but specifies the size of the part to be drawn. If you want to draw the whole image there is a simplified version of this function.
EXAMPLE:
drawImage(myImage, 10, 10, 20, 20, 40, 40);
| image | The image to draw. | |
| srcX | The source image x coordinate. | |
| srcY | The source image y coordinate. | |
| dstX | The destination x coordinate. | |
| dstY | The destination y coordinate. | |
| width | The width of the piece. | |
| height | The height of the piece. |
Implements gcn::Graphics.
Definition at line 143 of file sdlgraphics.cpp.
References gcn::SDLImage::getSurface(), gcn::Graphics::mClipStack, mTarget, gcn::ClipRectangle::xOffset, and gcn::ClipRectangle::yOffset.
| void gcn::SDLGraphics::drawLine | ( | int | x1, | |
| int | y1, | |||
| int | x2, | |||
| int | y2 | |||
| ) | [virtual] |
Ddraws a line.
| x1 | The first x coordinate. | |
| y1 | The first y coordinate. | |
| x2 | The second x coordinate. | |
| y2 | The second y coordinate. |
Implements gcn::Graphics.
Definition at line 503 of file sdlgraphics.cpp.
References drawHLine(), drawVLine(), gcn::Rectangle::isPointInRect(), mAlpha, gcn::Graphics::mClipStack, mColor, mTarget, gcn::SDLputPixel(), gcn::SDLputPixelAlpha(), gcn::ClipRectangle::xOffset, and gcn::ClipRectangle::yOffset.
| void gcn::SDLGraphics::drawPoint | ( | int | x, | |
| int | y | |||
| ) | [virtual] |
Draws a single point/pixel.
| x | The x coordinate. | |
| y | The y coordinate. |
Implements gcn::Graphics.
Definition at line 231 of file sdlgraphics.cpp.
References gcn::Rectangle::isPointInRect(), mAlpha, gcn::Graphics::mClipStack, mColor, mTarget, gcn::SDLputPixel(), gcn::SDLputPixelAlpha(), gcn::ClipRectangle::xOffset, and gcn::ClipRectangle::yOffset.
| void gcn::SDLGraphics::drawRectangle | ( | const Rectangle & | rectangle | ) | [virtual] |
Draws a simple, non-filled, rectangle with a one pixel width.
| rectangle | The rectangle to draw. |
Implements gcn::Graphics.
Definition at line 489 of file sdlgraphics.cpp.
References drawHLine(), drawVLine(), gcn::Rectangle::height, gcn::Rectangle::width, gcn::Rectangle::x, and gcn::Rectangle::y.
| void gcn::SDLGraphics::drawSDLSurface | ( | SDL_Surface * | surface, | |
| SDL_Rect | source, | |||
| SDL_Rect | destination | |||
| ) | [virtual] |
Draws an SDL_Surface on the target surface.
Normaly you'll use drawImage, but if you want to write SDL specific code this function might come in handy.
NOTE: The clip areas will be taken into account.
Definition at line 691 of file sdlgraphics.cpp.
References gcn::Graphics::mClipStack, mTarget, gcn::ClipRectangle::xOffset, and gcn::ClipRectangle::yOffset.
| void gcn::SDLGraphics::drawVLine | ( | int | x, | |
| int | y1, | |||
| int | y2 | |||
| ) | [protected, virtual] |
Draws a vertical line.
| x | the x coordinate of the line. | |
| y1 | the start coordinate of the line. | |
| y2 | the end coordinate of the line. |
Definition at line 375 of file sdlgraphics.cpp.
References gcn::Color::a, gcn::Color::b, gcn::Color::g, gcn::Rectangle::height, mAlpha, gcn::Graphics::mClipStack, mColor, mTarget, gcn::Color::r, gcn::SDLAlpha32(), gcn::Rectangle::width, gcn::Rectangle::x, gcn::ClipRectangle::xOffset, gcn::Rectangle::y, and gcn::ClipRectangle::yOffset.
Referenced by drawLine(), and drawRectangle().
| void gcn::SDLGraphics::fillRectangle | ( | const Rectangle & | rectangle | ) | [virtual] |
Draws a filled rectangle.
| rectangle | The filled rectangle to draw. |
Implements gcn::Graphics.
Definition at line 177 of file sdlgraphics.cpp.
References gcn::Color::a, gcn::Color::b, gcn::Color::g, gcn::Rectangle::height, gcn::Rectangle::isIntersecting(), mAlpha, gcn::Graphics::mClipStack, mColor, mTarget, gcn::Color::r, gcn::SDLputPixelAlpha(), gcn::Rectangle::width, gcn::Rectangle::x, gcn::ClipRectangle::xOffset, gcn::Rectangle::y, and gcn::ClipRectangle::yOffset.
| const Color & gcn::SDLGraphics::getColor | ( | ) | const [virtual] |
Gets the color to use when drawing.
Implements gcn::Graphics.
Definition at line 686 of file sdlgraphics.cpp.
References mColor.
| SDL_Surface * gcn::SDLGraphics::getTarget | ( | ) | const [virtual] |
Gets the target SDL_Surface.
Definition at line 138 of file sdlgraphics.cpp.
References mTarget.
| void gcn::SDLGraphics::popClipArea | ( | ) | [virtual] |
Removes the top most clip area from the stack.
| Exception | if the stack is empty. |
Reimplemented from gcn::Graphics.
Definition at line 119 of file sdlgraphics.cpp.
References gcn::Rectangle::height, gcn::Graphics::mClipStack, mTarget, gcn::Graphics::popClipArea(), gcn::Rectangle::width, gcn::Rectangle::x, and gcn::Rectangle::y.
Referenced by _endDraw().
| bool gcn::SDLGraphics::pushClipArea | ( | Rectangle | area | ) | [virtual] |
Pushes a clip area onto the stack.
The x and y coordinates in the rectangle is relative to the last pushed clip area. If the new area falls outside the current clip area, it will be clipped as necessary.
If a clip area is outside of the top clip area a clip area with zero width and height will be pushed.
| area | The clip area to be pushed onto the stack. |
Reimplemented from gcn::Graphics.
Definition at line 103 of file sdlgraphics.cpp.
References gcn::Rectangle::height, gcn::Graphics::mClipStack, mTarget, gcn::Graphics::pushClipArea(), gcn::Rectangle::width, gcn::Rectangle::x, and gcn::Rectangle::y.
Referenced by _beginDraw().
| void gcn::SDLGraphics::setColor | ( | const Color & | color | ) | [virtual] |
Sets the color to use when drawing.
| color | A color. |
Implements gcn::Graphics.
Definition at line 679 of file sdlgraphics.cpp.
References gcn::Color::a, mAlpha, and mColor.
| void gcn::SDLGraphics::setTarget | ( | SDL_Surface * | target | ) | [virtual] |
Sets the target SDL_Surface to draw to.
The target can be any SDL_Surface. This funtion also pushes a clip areas corresponding to the dimension of the target.
| target | the target to draw to. |
Definition at line 98 of file sdlgraphics.cpp.
References mTarget.
1.5.2