____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"#include <sdlgraphics.h>

Public Member Functions | |
| SDLGraphics () | |
| virtual void | setTarget (SDL_Surface *target) |
| virtual SDL_Surface * | getTarget () const |
| virtual void | drawSDLSurface (SDL_Surface *surface, SDL_Rect source, SDL_Rect destination) |
| virtual void | _beginDraw () |
| virtual void | _endDraw () |
| virtual bool | pushClipArea (Rectangle area) |
| virtual void | popClipArea () |
| virtual void | drawImage (const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height) |
| virtual void | drawPoint (int x, int y) |
| virtual void | drawLine (int x1, int y1, int x2, int y2) |
| virtual void | drawRectangle (const Rectangle &rectangle) |
| virtual void | fillRectangle (const Rectangle &rectangle) |
| virtual void | setColor (const Color &color) |
| virtual const Color & | getColor () |
Protected Member Functions | |
| virtual void | drawHLine (int x1, int y, int x2) |
| virtual void | drawVLine (int x, int y1, int y2) |
Protected Attributes | |
| SDL_Surface * | mTarget |
| Color | mColor |
| bool | mAlpha |
Definition at line 73 of file sdlgraphics.h.
| gcn::SDLGraphics::SDLGraphics | ( | ) |
| 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 96 of file sdlgraphics.cpp.
References mTarget.
| SDL_Surface * gcn::SDLGraphics::getTarget | ( | ) | const [virtual] |
Gets the target SDL_Surface.
Definition at line 136 of file sdlgraphics.cpp.
References mTarget.
| 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 622 of file sdlgraphics.cpp.
References gcn::Graphics::mClipStack, mTarget, gcn::ClipRectangle::xOffset, and gcn::ClipRectangle::yOffset.
| 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 would be OpenGLGraphics.
NOTE: You will never need to call this function yourself. Gui will do it for you.
Reimplemented from gcn::Graphics.
Definition at line 81 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. Gui will do it for you.
Reimplemented from gcn::Graphics.
Definition at line 91 of file sdlgraphics.cpp.
References popClipArea().
| bool gcn::SDLGraphics::pushClipArea | ( | Rectangle | area | ) | [virtual] |
Pushes a clip area onto the stack. The x and y coordinates in the Rectangle will be relative to the last pushed clip area. If the new area falls outside the current clip area, it will be clipped as necessary.
| area | the clip area to be pushed onto the stack. |
Reimplemented from gcn::Graphics.
Definition at line 101 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::popClipArea | ( | ) | [virtual] |
Removes the topmost clip area from the stack.
| Exception | if the stack is empty. |
Reimplemented from gcn::Graphics.
Definition at line 117 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().
| 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 | source Image x coordinate. | |
| srcY | source Image y coordinate. | |
| dstX | destination x coordinate. | |
| dstY | destination y coordinate. | |
| width | the width of the piece. | |
| height | the height of the piece. |
Implements gcn::Graphics.
Definition at line 141 of file sdlgraphics.cpp.
References gcn::Image::_getData(), gcn::Graphics::mClipStack, mTarget, 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 196 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::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 440 of file sdlgraphics.cpp.
References ABS, drawHLine(), drawVLine(), gcn::Rectangle::isPointInRect(), mAlpha, gcn::Graphics::mClipStack, mColor, mTarget, gcn::SDLputPixel(), gcn::SDLputPixelAlpha(), gcn::ClipRectangle::xOffset, y, and gcn::ClipRectangle::yOffset.
| void gcn::SDLGraphics::drawRectangle | ( | const Rectangle & | rectangle | ) | [virtual] |
Draws a simple, non-filled, Rectangle with one pixel width.
| rectangle | the Rectangle to draw. |
Implements gcn::Graphics.
Definition at line 426 of file sdlgraphics.cpp.
References drawHLine(), drawVLine(), gcn::Rectangle::height, gcn::Rectangle::width, gcn::Rectangle::x, and gcn::Rectangle::y.
| void gcn::SDLGraphics::fillRectangle | ( | const Rectangle & | rectangle | ) | [virtual] |
Draws a filled Rectangle.
| rectangle | the filled Rectangle to draw. |
Implements gcn::Graphics.
Definition at line 160 of file sdlgraphics.cpp.
References gcn::Color::a, gcn::Color::b, CVideo::FillTransRectangle(), gcn::Color::g, gcn::Rectangle::height, gcn::Rectangle::intersect(), mAlpha, gcn::Graphics::mClipStack, mColor, mTarget, gcn::Color::r, TheScreen, Video, gcn::Rectangle::width, gcn::Rectangle::x, gcn::ClipRectangle::xOffset, gcn::Rectangle::y, and gcn::ClipRectangle::yOffset.
| void gcn::SDLGraphics::setColor | ( | const Color & | color | ) | [virtual] |
Sets the Color to use when drawing.
| color | a Color. |
Implements gcn::Graphics.
Definition at line 610 of file sdlgraphics.cpp.
References gcn::Color::a, mAlpha, and mColor.
| const Color & gcn::SDLGraphics::getColor | ( | ) | [virtual] |
Gets the Color to use when drawing.
Implements gcn::Graphics.
Definition at line 617 of file sdlgraphics.cpp.
References mColor.
| 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 215 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::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 321 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().
SDL_Surface* gcn::SDLGraphics::mTarget [protected] |
Definition at line 157 of file sdlgraphics.h.
Referenced by _beginDraw(), drawHLine(), drawImage(), drawLine(), drawPoint(), drawSDLSurface(), drawVLine(), fillRectangle(), getTarget(), popClipArea(), pushClipArea(), and setTarget().
Color gcn::SDLGraphics::mColor [protected] |
Definition at line 158 of file sdlgraphics.h.
Referenced by drawHLine(), drawLine(), drawPoint(), drawVLine(), fillRectangle(), getColor(), and setColor().
bool gcn::SDLGraphics::mAlpha [protected] |
Definition at line 159 of file sdlgraphics.h.
Referenced by drawHLine(), drawLine(), drawPoint(), drawVLine(), fillRectangle(), SDLGraphics(), and setColor().
1.5.6