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