| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <vector> |
| 4 |
#include <limits> |
| 5 |
#include <cstdint> |
| 6 |
#include "render/RenderVertex.h" |
| 7 |
|
| 8 |
class IRenderEntity; |
| 9 |
|
| 10 |
namespace render |
| 11 |
{ |
| 12 |
|
| 13 |
/** |
| 14 |
* A winding renderer accepts a variable number of windings and arranges them into |
| 15 |
* one or more continuous blocks of vertices for efficient rendering. |
| 16 |
* |
| 17 |
* The internal arrangement has the goal of reducing the amount of draw calls for |
| 18 |
* winding sharing a single material. Allocating a winding slot yields a handle which |
| 19 |
* allows for later update or deallocation of the slot. |
| 20 |
* |
| 21 |
* Only the vertex data (XYZ, UV, Normals, Colour) needs to be submitted, |
| 22 |
* the render indices of each winding slot are handled internally. |
| 23 |
*/ |
| 24 |
class IWindingRenderer |
| 25 |
{ |
| 26 |
public: |
| 27 |
virtual ~IWindingRenderer() {} |
| 28 |
|
| 29 |
using Slot = std::uint64_t; |
| 30 |
static constexpr Slot InvalidSlot = std::numeric_limits<Slot>::max(); |
| 31 |
|
| 32 |
// Allocate a slot to hold the vertex data of a winding of the given size. |
| 33 |
// The winding will be associated to the given render entity (causing it to be grouped internally |
| 34 |
// by the render entities when the surfaces are processed in lit render views). |
| 35 |
// Returns the handle which can be used to update or deallocate the data later |
| 36 |
virtual Slot addWinding(const std::vector<RenderVertex>& vertices, IRenderEntity* entity) = 0; |
| 37 |
|
| 38 |
// Releases a previously allocated winding slot. This invalidates the handle. |
| 39 |
virtual void removeWinding(Slot slot) = 0; |
| 40 |
|
| 41 |
// Updates the winding data. An IRenderEntity change is not supported through updateWinding(), in case the |
| 42 |
// winding has to be associated to a different entity, call removeWinding() first. |
| 43 |
virtual void updateWinding(Slot slot, const std::vector<RenderVertex>& vertices) = 0; |
| 44 |
|
| 45 |
// Mode used to specify how to render a single winding |
| 46 |
enum class RenderMode |
| 47 |
{ |
| 48 |
Triangles, |
| 49 |
Polygon, |
| 50 |
}; |
| 51 |
|
| 52 |
// Submits a single winding to GL |
| 53 |
virtual void renderWinding(RenderMode mode, Slot slot) = 0; |
| 54 |
}; |
| 55 |
|
| 56 |
} |