class EE::Graphics::Primitives

Overview

Basic primitives rendering class. More…

#include <primitives.hpp>

class Primitives {
public:
    // construction

    ~Primitives();

    // methods

    void drawPoint(const Vector2f& p, const Float& pointSize = 1.0f);
    void drawLine(const Line2f& line);
    void drawArc(const Vector2f& p, const Float& radius, Uint32 segmentsCount = 0, const Float& arcAngle = 360.f, const Float& arcStartAngle = 0.f);
    void drawCircle(const Vector2f& p, const Float& radius, Uint32 segmentsCount = 0);
    void drawTriangle(const Triangle2f& t);
    void drawTriangle(const Triangle2f& t, const Color& Color1, const Color& Color2, const Color& Color3);
    void drawRectangle(const Rectf& R, const Float& Angle, const Vector2f& Scale = Vector2f::One);
    void drawRectangle(const Rectf& R);
    void drawRoundedRectangle(const Rectf& R, const Float& Angle = 0, const Vector2f& Scale = Vector2f::One, const unsigned int& Corners = 8);

    void drawRectangle(
        const Rectf& R,
        const Color& TopLeft,
        const Color& BottomLeft,
        const Color& BottomRight,
        const Color& TopRight,
        const Float& Angle = 0,
        const Vector2f& Scale = Vector2f::One
    );

    void drawRoundedRectangle(
        const Rectf& R,
        const Color& TopLeft,
        const Color& BottomLeft,
        const Color& BottomRight,
        const Color& TopRight,
        const Float& Angle = 0,
        const Vector2f& Scale = Vector2f::One,
        const unsigned int& Corners = 8
    );

    void drawQuad(const Quad2f& q, const Float& OffsetX = 0, const Float& OffsetY = 0);

    void drawQuad(
        const Quad2f& q,
        const Color& Color1,
        const Color& Color2,
        const Color& Color3,
        const Color& Color4,
        const Float& OffsetX = 0,
        const Float& OffsetY = 0
    );

    void drawPolygon(const Polygon2f& p);
    void setColor(const Color& Color);
    const Color& getColor();
    void setForceDraw(const bool& force);
    const bool& getForceDraw() const;
    void drawBatch();
    void setFillMode(const PrimitiveFillMode& Mode);
    const PrimitiveFillMode& getFillMode() const;
    void setBlendMode(const BlendMode& Mode);
    const BlendMode& getBlendMode() const;
    void setLineWidth(const Float& width);
    const Float& getLineWidth() const;
};

Detailed Documentation

Basic primitives rendering class.

Methods

void drawPoint(const Vector2f& p, const Float& pointSize = 1.0f)

Draw a point on the screen

Parameters:

p

The coordinates

pointSize

Point Size (default 1.0f )

void drawLine(const Line2f& line)

Draw a Line on screen

Parameters:

line

The line

void drawArc(const Vector2f& p, const Float& radius, Uint32 segmentsCount = 0, const Float& arcAngle = 360.f, const Float& arcStartAngle = 0.f)

Draw an arc on the screen

Parameters:

p

The coordinates ( x and y represents the center of the circle )

radius

The Circle Radius

segmentsCount

Number of segments to represent the circle

arcAngle

The arc angle

arcStartAngle

The arc starting point angle

void drawCircle(const Vector2f& p, const Float& radius, Uint32 segmentsCount = 0)

Draw a circle on the screen

Parameters:

p

The coordinates ( x and y represents the center of the circle )

radius

The Circle Radius

segmentsCount

Number of segments to represent the circle. If segmentsCount is equal to 0 by default will use an optimized circle rendering ( precached coordinates ).

void drawTriangle(const Triangle2f& t)

Draw a triangle on the screen

Parameters:

t

The Triangle (Triangle2f)

void drawTriangle(const Triangle2f& t, const Color& Color1, const Color& Color2, const Color& Color3)

Draw a triangle on the screen setting per vertex color

Parameters:

t

The Triangle (Triangle2f)

Color1

First Point Color

Color2

Second Point Color

Color3

Third Point Color

void drawRectangle(const Rectf& R, const Float& Angle, const Vector2f& Scale = Vector2f::One)

Draw a rectangle on the screen

Parameters:

R

The Rectangle Rectf

Angle

Rectangle Angle

Scale

Rectangle Scale ( default 1.0f )

void drawRectangle(const Rectf& R)

Draw a rectangle on the screen

Parameters:

R

The Rectangle Rectf

void drawRoundedRectangle(const Rectf& R, const Float& Angle = 0, const Vector2f& Scale = Vector2f::One, const unsigned int& Corners = 8)

Draw a rounded rectangle on the screen

Parameters:

R

The Rectangle Rectf

Angle

Rectangle Angle

Scale

Rectangle Scale ( default 1.0f )

Corners

Number of vertices per corner ( how rounded is each corner )

void drawRectangle(
    const Rectf& R,
    const Color& TopLeft,
    const Color& BottomLeft,
    const Color& BottomRight,
    const Color& TopRight,
    const Float& Angle = 0,
    const Vector2f& Scale = Vector2f::One
)

Draw a rectangle on the screen setting per vertex color

Parameters:

R

The Rectangle Rectf

TopLeft

The Top Left Rectangle Color

BottomLeft

The Bottom Left Rectangle Color

BottomRight

The Bottom Right Rectangle Color

TopRight

The Top Right Rectangle Color

Angle

Rectangle Angle

Scale

Rectangle Scale ( default 1.0f )

void drawRoundedRectangle(
    const Rectf& R,
    const Color& TopLeft,
    const Color& BottomLeft,
    const Color& BottomRight,
    const Color& TopRight,
    const Float& Angle = 0,
    const Vector2f& Scale = Vector2f::One,
    const unsigned int& Corners = 8
)

Draw a rounded rectangle on the screen setting per vertex color

Parameters:

R

The Rectangle Rectf

TopLeft

The Top Left Rectangle Color

BottomLeft

The Bottom Left Rectangle Color

BottomRight

The Bottom Right Rectangle Color

TopRight

The Top Right Rectangle Color

Angle

Rectangle Angle

Scale

Rectangle Scale ( default 1.0f )

Corners

Number of vertices per corner ( how rounded is each corner )

void drawQuad(const Quad2f& q, const Float& OffsetX = 0, const Float& OffsetY = 0)

Draw a four edges polygon on screen

Parameters:

q

The Quad

OffsetX

X offset for the quad

OffsetY

Y offset for the quad

void drawQuad(
    const Quad2f& q,
    const Color& Color1,
    const Color& Color2,
    const Color& Color3,
    const Color& Color4,
    const Float& OffsetX = 0,
    const Float& OffsetY = 0
)

Draw a four edges polygon on screen

Parameters:

q

The Quad

Color1

First Point Color

Color2

Second Point Color

Color3

Third Point Color

Color4

Fourth Point Color

OffsetX

X offset for the quad

OffsetY

Y offset for the quad

void drawPolygon(const Polygon2f& p)

Draw a polygon on screen

Parameters:

p

The Polygon

void setColor(const Color& Color)

Set the current color for drawing primitives

const Color& getColor()

Returns:

The color used to draw the primitives

void setForceDraw(const bool& force)

Forcing the draw, will force the batch renderer to draw the batched vertexs immediately ( active by default ).

void drawBatch()

Force to draw the batched vertexs.

void setFillMode(const PrimitiveFillMode& Mode)

Set the fill mode used to draw primitives

const PrimitiveFillMode& getFillMode() const

Returns:

The fill mode used to draw primitives

void setBlendMode(const BlendMode& Mode)

Set the blend mode used to draw primitives

const BlendMode& getBlendMode() const

Returns:

The blend mode used to draw primitives

void setLineWidth(const Float& width)

Set the line width to draw primitives

const Float& getLineWidth() const

Returns:

The line with to draw primitives