class EE::Graphics::BatchRenderer

Overview

A batch rendering class. More…

#include <batchrenderer.hpp>

class BatchRenderer {
public:
    // construction

    BatchRenderer();
    BatchRenderer(const unsigned int& Prealloc);
    virtual ~BatchRenderer();

    // methods

    static BatchRenderer* New();
    static BatchRenderer* New(const unsigned int& Prealloc);
    void allocVertexs(const unsigned int& size);
    void setTexture(const Texture* texture, Texture::CoordinateType coordinateType = Texture::CoordinateType::Normalized);
    void setBlendMode(const BlendMode& blend);
    void setBatchForceRendering(const bool& force);
    bool getBatchForceRendering() const;
    void draw();
    void drawOpt();
    void setBatchRotation(const Float& Rotation);
    Float getBatchRotation() const;
    void setBatchScale(const Vector2f& Scale);
    void setBatchScale(const Float& Scale);
    Vector2f getBatchScale() const;
    void setBatchPosition(const Vector2f Pos);
    Vector2f getBatchPosition() const;
    void setBatchCenter(const Vector2f Pos);
    Vector2f getBatchCenter() const;

    void batchQuadEx(
        Float x,
        Float y,
        Float width,
        Float height,
        Float angle = 0.0f,
        Vector2f scale = Vector2f::One,
        OriginPoint originPoint = OriginPoint(OriginPoint::OriginCenter)
    );

    void batchQuad(const Float& x, const Float& y, const Float& width, const Float& height);
    void batchQuad(const Rectf& rect);

    void batchQuadFree(
        const Float& x0,
        const Float& y0,
        const Float& x1,
        const Float& y1,
        const Float& x2,
        const Float& y2,
        const Float& x3,
        const Float& y3
    );

    void batchQuadFreeEx(
        const Float& x0,
        const Float& y0,
        const Float& x1,
        const Float& y1,
        const Float& x2,
        const Float& y2,
        const Float& x3,
        const Float& y3,
        const Float& Angle = 0.0f,
        const Float& Scale = 1.0f
    );

    void quadsBegin();
    void quadsSetTexCoord(const Float& tl_u, const Float& tl_v, const Float& br_u, const Float& br_v);
    void quadsSetTexCoord(const Rectf& region);

    void quadsSetTexCoordFree(
        const Float& x0,
        const Float& y0,
        const Float& x1,
        const Float& y1,
        const Float& x2,
        const Float& y2,
        const Float& x3,
        const Float& y3
    );

    void quadsSetColor(const Color& Color);
    void quadsSetColorFree(const Color& Color0, const Color& Color1, const Color& Color2, const Color& Color3);
    void pointsBegin();
    void pointSetColor(const Color& Color);
    void pointSetTexCoord(const Float& x, const Float& y);
    void batchPoint(const Float& x, const Float& y, const PrimitiveType& primitiveType = PRIMITIVE_POINTS);
    void batchPointList(const std::vector<VertexData>& points, const PrimitiveType& primitiveType = PRIMITIVE_POINTS);
    void linesBegin();
    void linesSetColor(const Color& Color);
    void linesSetColorFree(const Color& Color0, const Color& Color1);
    void batchLine(const Float& x0, const Float& y0, const Float& x1, const Float& y1);
    void lineLoopBegin();
    void lineLoopSetColor(const Color& Color);
    void lineLoopSetColorFree(const Color& Color0, const Color& Color1);
    void batchLineLoop(const Float& x0, const Float& y0, const Float& x1, const Float& y1);
    void batchLineLoop(const Float& x0, const Float& y0);
    void batchLineLoop(const Vector2f& vector1, const Vector2f& vector2);
    void batchLineLoop(const Vector2f& vector1);
    void lineStripBegin();
    void lineStripSetColor(const Color& Color);
    void lineStripSetColorFree(const Color& Color0, const Color& Color1);
    void batchLineStrip(const Float& x0, const Float& y0, const Float& x1, const Float& y1);
    void batchLineStrip(const Float& x0, const Float& y0);
    void batchLineStrip(const Vector2f& vector1, const Vector2f& vector2);
    void batchLineStrip(const Vector2f& vector1);
    void triangleFanBegin();
    void triangleFanSetColor(const Color& Color);
    void triangleFanSetColorFree(const Color& Color0, const Color& Color1, const Color& Color2);
    void triangleFanSetTexCoord(const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2);
    void batchTriangleFan(const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2);
    void batchTriangleFan(const Float& x0, const Float& y0);
    void trianglesBegin();
    void trianglesSetColor(const Color& Color);
    void trianglesSetColorFree(const Color& Color0, const Color& Color1, const Color& Color2);
    void trianglesSetTexCoord(const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2);
    void batchTriangle(const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2);
    void polygonSetColor(const Color& Color);
    void batchPolygon(const Polygon2f& Polygon);
    void setLineWidth(const Float& lineWidth);
    Float getLineWidth();
    void setPointSize(const Float& pointSize);
    Float getPointSize();
    void batchPolygonByPoint(const Float& x, const Float& y);
    void batchPolygonByPoint(const Vector2f& Vector);
    void setForceBlendModeChange(const bool& Force);
    const bool& getForceBlendModeChange() const;
};

Detailed Documentation

A batch rendering class.

Construction

BatchRenderer(const unsigned int& Prealloc)

Construct with a defined number of vertexs preallocated

Methods

void allocVertexs(const unsigned int& size)

Allocate space for vertexs

void setTexture(const Texture* texture, Texture::CoordinateType coordinateType = Texture::CoordinateType::Normalized)

Set the current texture to render on the batch ( if you change the texture and you have batched something, this will be renderer immediately )

void setBlendMode(const BlendMode& blend)

Set the predefined blending function to use on the batch

void setBatchForceRendering(const bool& force)

Set if every batch call have to be immediately rendered

bool getBatchForceRendering() const

Get if the rendering is force on every batch call

void draw()

Force the batch rendering

void drawOpt()

Force the batch rendering only if BatchForceRendering is enable

void setBatchRotation(const Float& Rotation)

Set the rotation of the rendered vertex.

Float getBatchRotation() const

Get the rotation of the rendered vertex.

void setBatchScale(const Vector2f& Scale)

Set the scale of the rendered vertex.

void setBatchScale(const Float& Scale)

Set the scale of the rendered vertex.

Vector2f getBatchScale() const

Get the scale of the rendered vertex.

void setBatchPosition(const Vector2f Pos)

The batch position

Vector2f getBatchPosition() const

Returns:

The batch position

void setBatchCenter(const Vector2f Pos)

This will set a center position for rotating and scaling the batched vertex.

Vector2f getBatchCenter() const

Returns:

The batch center position

void batchQuadEx(
    Float x,
    Float y,
    Float width,
    Float height,
    Float angle = 0.0f,
    Vector2f scale = Vector2f::One,
    OriginPoint originPoint = OriginPoint(OriginPoint::OriginCenter)
)

Add to the batch a quad ( this will change your batch rendering method to PRIMITIVE_QUADS, so if you were using another one will Draw all the batched vertexs first )

void batchQuad(const Float& x, const Float& y, const Float& width, const Float& height)

Add to the batch a quad ( this will change your batch rendering method to PRIMITIVE_QUADS, so if you were using another one will Draw all the batched vertexs first )

void batchQuad(const Rectf& rect)

Add to the batch a quad ( this will change your batch rendering method to PRIMITIVE_QUADS, so if you were using another one will Draw all the batched vertexs first )

void batchQuadFree(
    const Float& x0,
    const Float& y0,
    const Float& x1,
    const Float& y1,
    const Float& x2,
    const Float& y2,
    const Float& x3,
    const Float& y3
)

Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to PRIMITIVE_QUADS, so if you were using another one will Draw all the batched vertexs first )

void batchQuadFreeEx(
    const Float& x0,
    const Float& y0,
    const Float& x1,
    const Float& y1,
    const Float& x2,
    const Float& y2,
    const Float& x3,
    const Float& y3,
    const Float& Angle = 0.0f,
    const Float& Scale = 1.0f
)

Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to PRIMITIVE_QUADS, so if you were using another one will Draw all the batched vertexs first )

void quadsBegin()

This will set as the default batch rendering to GL_QUADS. WIll reset the texture TexCoord rendering to the whole texture. Will reset the default color rendering to ColorA(255,255,255,255).

void quadsSetTexCoord(const Float& tl_u, const Float& tl_v, const Float& br_u, const Float& br_v)

Set the texture sector to be rendered

void quadsSetTexCoord(const Rectf& region)

Set the texture sector to be rendered

void quadsSetTexCoordFree(
    const Float& x0,
    const Float& y0,
    const Float& x1,
    const Float& y1,
    const Float& x2,
    const Float& y2,
    const Float& x3,
    const Float& y3
)

Set the texture sector to be rendered but freely seted

void quadsSetColor(const Color& Color)

Set the quad color

void quadsSetColorFree(const Color& Color0, const Color& Color1, const Color& Color2, const Color& Color3)

Set the quad color per vertex

void pointsBegin()

This will set as the default batch rendering to PRIMITIVE_POINTS. And will reset the point color to ColorA(255,255,255,255).

void pointSetColor(const Color& Color)

Set the point color

void pointSetTexCoord(const Float& x, const Float& y)

Set the texture sector to be rendered

void batchPoint(const Float& x, const Float& y, const PrimitiveType& primitiveType = PRIMITIVE_POINTS)

Adds to the batch a point

void batchPointList(const std::vector<VertexData>& points, const PrimitiveType& primitiveType = PRIMITIVE_POINTS)

Adds to the batch a point list

void linesBegin()

This will set as the default batch rendering to PRIMITIVE_LINES. And will reset the line color to ColorA(255,255,255,255).

void linesSetColor(const Color& Color)

Set the line color

void linesSetColorFree(const Color& Color0, const Color& Color1)

Set the line color, per vertex

void batchLine(const Float& x0, const Float& y0, const Float& x1, const Float& y1)

Add to the batch a line ( this will change your batch rendering method to PRIMITIVE_LINES, so if you were using another one will Draw all the batched vertexs first )

void lineLoopBegin()

This will set as the default batch rendering to GL_LINE_LOOP. And will reset the line color to ColorA(255,255,255,255).

void lineLoopSetColor(const Color& Color)

Set the line color

void lineLoopSetColorFree(const Color& Color0, const Color& Color1)

Set the line color, per vertex

void batchLineLoop(const Float& x0, const Float& y0, const Float& x1, const Float& y1)

Add to the batch a line ( this will change your batch rendering method to PRIMITIVE_LINE_LOOP, so if you were using another one will Draw all the batched vertexs first )

void batchLineLoop(const Float& x0, const Float& y0)

Add to the batch a point to the line loop batch ( this will change your batch rendering method to PRIMITIVE_LINE_LOOP, so if you were using another one will Draw all the batched vertexs first )

void batchLineLoop(const Vector2f& vector1, const Vector2f& vector2)

Add to the batch a line ( this will change your batch rendering method to PRIMITIVE_LINE_LOOP, so if you were using another one will Draw all the batched vertexs first )

void batchLineLoop(const Vector2f& vector1)

Add to the batch a point to the line loop batch ( this will change your batch rendering method to PRIMITIVE_LINE_LOOP, so if you were using another one will Draw all the batched vertexs first )

void lineStripBegin()

This will set as the default batch rendering to PRIMITIVE_LINE_STRIP. And will reset the line color to ColorA(255,255,255,255).

void lineStripSetColor(const Color& Color)

Set the line color

void lineStripSetColorFree(const Color& Color0, const Color& Color1)

Set the line color, per vertex

void batchLineStrip(const Float& x0, const Float& y0, const Float& x1, const Float& y1)

Add to the batch a line ( this will change your batch rendering method to PRIMITIVE_LINE_STRIP, so if you were using another one will Draw all the batched vertexs first )

void batchLineStrip(const Float& x0, const Float& y0)

Add to the batch a point to the line strip batch ( this will change your batch rendering method to PRIMITIVE_LINE_STRIP, so if you were using another one will Draw all the batched vertexs first )

void batchLineStrip(const Vector2f& vector1, const Vector2f& vector2)

Add to the batch a line ( this will change your batch rendering method to PRIMITIVE_LINE_STRIP, so if you were using another one will Draw all the batched vertexs first )

void batchLineStrip(const Vector2f& vector1)

Add to the batch a point to the line strip batch ( this will change your batch rendering method to PRIMITIVE_LINE_STRIP, so if you were using another one will Draw all the batched vertexs first )

void triangleFanBegin()

This will set as the default batch rendering to PRIMITIVE_TRIANGLE_FAN. And will reset the line color to ColorA(255,255,255,255).

void triangleFanSetColor(const Color& Color)

Set the triangle fan color

void triangleFanSetColorFree(const Color& Color0, const Color& Color1, const Color& Color2)

Set the triangle fan color, per vertex

void triangleFanSetTexCoord(const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2)

Set the texture sector to be rendered but freely seted

void batchTriangleFan(const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2)

Add to the batch a triangle fan ( this will change your batch rendering method to PRIMITIVE_TRIANGLE_FAN, so if you were using another one will Draw all the batched vertexs first )

void batchTriangleFan(const Float& x0, const Float& y0)

Add to the batch a triangle fan ( this will change your batch rendering method to PRIMITIVE_TRIANGLE_FAN, so if you were using another one will Draw all the batched vertexs first )

void trianglesBegin()

This will set as the default batch rendering to PRIMITIVE_TRIANGLES. And will reset the line color to ColorA(255,255,255,255).

void trianglesSetColor(const Color& Color)

Set the triangles color

void trianglesSetColorFree(const Color& Color0, const Color& Color1, const Color& Color2)

Set the triangles color, per vertex

void trianglesSetTexCoord(const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2)

Set the texture sector to be rendered but freely seted

void batchTriangle(const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2)

Add to the batch a triangle ( this will change your batch rendering method to PRIMITIVE_TRIANGLES, so if you were using another one will Draw all the batched vertexs first )

void polygonSetColor(const Color& Color)

Set the polygon color

void batchPolygon(const Polygon2f& Polygon)

Add to the batch a polygon ( this will change your batch rendering method to PRIMITIVE_POLYGON, so if you were using another one will Draw all the batched vertexs first )

void setLineWidth(const Float& lineWidth)

Set the line width

Float getLineWidth()

Returns:

The current line width

void setPointSize(const Float& pointSize)

Set the point size

Float getPointSize()

Returns:

The current point size

void batchPolygonByPoint(const Float& x, const Float& y)

Batch a poligon adding one by one vector

void batchPolygonByPoint(const Vector2f& Vector)

Batch a poligon adding one by one vector

void setForceBlendModeChange(const bool& Force)

Foce the blending mode change, ignoring if it’s the same that before ( so you can change the blend mode and restore it without problems )

const bool& getForceBlendModeChange() const

Returns:

If the blending mode switch is forced