|
FifeGUI 0.2.0
A C++ GUI library designed for games.
|
#include <graphics.hpp>
Public Member Functions | |
| void | _beginDraw () override |
| void | _endDraw () override |
| void | drawBezier (PointVector const &points, int steps, unsigned int width) override |
| void | drawCircle (Point const &p, unsigned int radius) override |
| void | drawCircleSegment (Point const &p, unsigned int radius, int sangle, int eangle) override |
| void | drawFillCircle (Point const &p, unsigned int radius) override |
| void | drawFillCircleSegment (Point const &p, unsigned int radius, int sangle, int eangle) override |
| void | drawImage (fcn::Image const *image, int srcX, int srcY, int dstX, int dstY, int width, int height) override |
| void | drawImage (fcn::opengl::Image const *image, int srcX, int srcY, int dstX, int dstY, int width, int height) |
| virtual void | drawImage (Image const *image, int dstX, int dstY) |
| void | drawLine (int x1, int y1, int x2, int y2) override |
| void | drawLine (int x1, int y1, int x2, int y2, unsigned int width) override |
| void | drawPoint (int x, int y) override |
| void | drawPolyLine (PointVector const &points, unsigned int width) override |
| void | drawRectangle (Rectangle const &rectangle) override |
| void | fillRectangle (Rectangle const &rectangle) override |
| Color const & | getColor () const override |
| virtual int | getTargetPlaneHeight () const |
| virtual int | getTargetPlaneWidth () const |
| Graphics () | |
| Graphics (Graphics &&)=delete | |
| Graphics (Graphics const &)=delete | |
| Graphics (int width, int height) | |
| Graphics & | operator= (Graphics &&)=delete |
| Graphics & | operator= (Graphics const &)=delete |
| void | popClipArea () override |
| bool | pushClipArea (Rectangle area) override |
| void | setColor (Color const &color) override |
| virtual void | setTargetPlane (int width, int height) |
| Public Member Functions inherited from fcn::Graphics | |
| virtual std::shared_ptr< Font > | createFont (std::string const &filename, int size) |
| void | drawRectangle (int x, int y, int width, int height) |
| virtual void | drawRoundStroke (int x1, int y1, int x2, int y2, unsigned int width) |
| void | drawText (std::string const &text, int x, int y) |
| virtual void | drawText (std::string const &text, int x, int y, Alignment alignment) |
| void | fillRectangle (int x, int y, int width, int height) |
| virtual ClipRectangle const & | getCurrentClipArea () |
| Graphics (Graphics &&)=delete | |
| Graphics (Graphics const &)=delete | |
| Graphics & | operator= (Graphics &&)=delete |
| Graphics & | operator= (Graphics const &)=delete |
| virtual void | setFont (Font *font) |
Protected Attributes | |
| bool | mAlpha {} |
| Color | mColor |
| int | mHeight {} |
| int | mWidth {} |
| Protected Attributes inherited from fcn::Graphics | |
| std::stack< ClipRectangle > | mClipStack |
| Font * | mFont {nullptr} |
Additional Inherited Members | |
| Public Types inherited from fcn::Graphics | |
| enum class | Alignment : uint8_t { Left = 0 , Center , Right } |
OpenGL-specific implementation of the Graphics interface.
Definition at line 20 of file backends/opengl/graphics.hpp.
| fcn::opengl::Graphics::Graphics | ( | ) |
Constructor.
Definition at line 22 of file backends/opengl/graphics.cpp.
References setTargetPlane().
| fcn::opengl::Graphics::Graphics | ( | int | width, |
| int | height ) |
Constructor.
| width | the width of the logical drawing surface. Should be the same as the screen resolution. |
| height | the height ot the logical drawing surface. Should be the same as the screen resolution. |
Definition at line 27 of file backends/opengl/graphics.cpp.
References setTargetPlane().
|
overridevirtualdefault |
Reimplemented from fcn::Graphics.
|
overridevirtual |
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 the library.
Reimplemented from fcn::Graphics.
Definition at line 34 of file backends/opengl/graphics.cpp.
References mHeight, mWidth, and pushClipArea().
|
overridevirtual |
Deinitializes the drawing process.
Called by the GUI when Gui::draw() is complete. It should reset any state changes made by _beginDraw().
NOTE: You generally won't need to call this function yourself unless you are using a Graphics object outside of the library.
Reimplemented from fcn::Graphics.
Definition at line 71 of file backends/opengl/graphics.cpp.
References popClipArea().
|
overridevirtual |
Draws a bezier curve.
| points | The coordinates as points in a vector. |
| steps | The steps for each line between two points. |
| width | The line width. |
Implements fcn::Graphics.
Definition at line 230 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a simple, non-filled circle with a one pixel width.
| p | The circle center coordinate as point. |
| radius | The circle radius. |
Implements fcn::Graphics.
Definition at line 269 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a simple, non-filled circle segment with a one pixel width.
Note: The start angle must be less than the end angle. 0 angle is right side.
| p | The circle center coordinate as point. |
| radius | The circle radius. |
| sangle | The start angle of the segment. |
| eangle | The end angle of the segment. |
Implements fcn::Graphics.
Definition at line 279 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a filled circle.
| p | The circle center coordinate as point. |
| radius | The circle radius. |
Implements fcn::Graphics.
Definition at line 274 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a filled circle segment.
Note: The start angle must be less than the end angle. 0 angle is right side.
| p | The circle center coordinate as point. |
| radius | The circle radius. |
| sangle | The start angle of the segment. |
| eangle | The end angle of the segment. |
Implements fcn::Graphics.
Definition at line 284 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
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:
Will draw a rectangular piece of myImage starting at coordinate (10, 10) in myImage, with width and height 40. The piece will be drawn with it's top left corner at coordinate (20, 20).
| 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 fcn::Graphics.
Definition at line 121 of file backends/opengl/graphics.cpp.
References fcn::Graphics::mClipStack, fcn::ClipRectangle::xOffset, and fcn::ClipRectangle::yOffset.
| void fcn::opengl::Graphics::drawImage | ( | fcn::opengl::Image const * | image, |
| int | srcX, | ||
| int | srcY, | ||
| int | dstX, | ||
| int | dstY, | ||
| int | width, | ||
| int | height ) |
Draws an OpenGL-specific image.
| image | Pointer to the OpenGL image to draw. |
| srcX | Source X coordinate. |
| srcY | Source Y coordinate. |
| dstX | Destination X coordinate. |
| dstY | Destination Y coordinate. |
| width | Width of the region to draw. |
| height | Height of the region to draw. |
References drawBezier(), drawCircle(), drawCircleSegment(), drawFillCircle(), drawFillCircleSegment(), drawLine(), drawPoint(), drawPolyLine(), drawRectangle(), fillRectangle(), getColor(), and setColor().
|
virtual |
Draws an image.
A simplified version of the other drawImage. It will draw a whole image at the coordinate you specify. It is equivalent to calling:
Reimplemented from fcn::Graphics.
Definition at line 163 of file graphics.cpp.
|
overridevirtual |
Draws a line.
| x1 | The first x coordinate. |
| y1 | The first y coordinate. |
| x2 | The second x coordinate. |
| y2 | The second y coordinate. |
Implements fcn::Graphics.
Definition at line 192 of file backends/opengl/graphics.cpp.
References fcn::Graphics::mClipStack, fcn::ClipRectangle::xOffset, and fcn::ClipRectangle::yOffset.
Referenced by drawImage().
|
overridevirtual |
Draws a thick line.
| x1 | The first x coordinate. |
| y1 | The first y coordinate. |
| x2 | The second x coordinate. |
| y2 | The second y coordinate. |
| width | The line width. |
Implements fcn::Graphics.
Definition at line 220 of file backends/opengl/graphics.cpp.
|
overridevirtual |
Draws a single point/pixel.
| x | The x coordinate. |
| y | The y coordinate. |
Implements fcn::Graphics.
Definition at line 175 of file backends/opengl/graphics.cpp.
References fcn::Graphics::mClipStack, fcn::ClipRectangle::xOffset, and fcn::ClipRectangle::yOffset.
Referenced by drawImage().
|
overridevirtual |
Draws lines between points with given width.
| points | Contains the points that are used for drawing. |
| width | The line width. |
Implements fcn::Graphics.
Definition at line 225 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a simple, non-filled rectangle with a one pixel width.
| rectangle | The rectangle to draw. |
Implements fcn::Graphics.
Definition at line 235 of file backends/opengl/graphics.cpp.
References fcn::Rectangle::height, fcn::Graphics::mClipStack, fcn::Rectangle::width, fcn::Rectangle::x, fcn::ClipRectangle::xOffset, fcn::Rectangle::y, and fcn::ClipRectangle::yOffset.
Referenced by drawImage().
|
overridevirtual |
Draws a filled rectangle.
| rectangle | The filled rectangle to draw. |
Implements fcn::Graphics.
Definition at line 252 of file backends/opengl/graphics.cpp.
References fcn::Rectangle::height, fcn::Graphics::mClipStack, fcn::Rectangle::width, fcn::Rectangle::x, fcn::ClipRectangle::xOffset, fcn::Rectangle::y, and fcn::ClipRectangle::yOffset.
Referenced by drawImage().
|
overridevirtual |
Gets the color to use when drawing.
Implements fcn::Graphics.
Definition at line 305 of file backends/opengl/graphics.cpp.
References mColor.
Referenced by drawImage().
|
virtual |
Gets the target plane height.
Definition at line 315 of file backends/opengl/graphics.cpp.
References mHeight.
|
virtual |
Gets the target plane width.
Definition at line 310 of file backends/opengl/graphics.cpp.
References mWidth.
|
overridevirtual |
Removes the top most clip area from the stack.
| Exception | if the stack is empty. |
Reimplemented from fcn::Graphics.
Definition at line 100 of file backends/opengl/graphics.cpp.
References fcn::Graphics::mClipStack, mHeight, and popClipArea().
Referenced by _endDraw(), and popClipArea().
|
overridevirtual |
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 fcn::Graphics.
Definition at line 87 of file backends/opengl/graphics.cpp.
References fcn::Graphics::mClipStack, mHeight, and fcn::Graphics::pushClipArea().
Referenced by _beginDraw().
|
overridevirtual |
Sets the color to use when drawing.
| color | A color. |
Implements fcn::Graphics.
Definition at line 289 of file backends/opengl/graphics.cpp.
References fcn::Color::a, fcn::Color::b, fcn::Color::g, mAlpha, mColor, and fcn::Color::r.
Referenced by drawImage().
|
virtual |
Sets the target plane on where to draw.
| width | the width of the logical drawing surface. Should be the same as the screen resolution. |
| height | the height ot the logical drawing surface. Should be the same as the screen resolution. |
Definition at line 115 of file backends/opengl/graphics.cpp.
References mHeight, and mWidth.
Referenced by Graphics(), and Graphics().
|
protected |
Whether alpha blending is enabled.
Definition at line 132 of file backends/opengl/graphics.hpp.
Referenced by setColor().
|
protected |
Current drawing color.
Definition at line 135 of file backends/opengl/graphics.hpp.
Referenced by getColor(), and setColor().
|
protected |
Height of the logical target plane.
Definition at line 129 of file backends/opengl/graphics.hpp.
Referenced by _beginDraw(), getTargetPlaneHeight(), popClipArea(), pushClipArea(), and setTargetPlane().
|
protected |
Width of the logical target plane.
Definition at line 126 of file backends/opengl/graphics.hpp.
Referenced by _beginDraw(), getTargetPlaneWidth(), and setTargetPlane().