blob: fe98ec650528939ec7b30f3e3bd5622a553f843d (
plain)
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
|
#pragma once
#include <memory>
#include <cassert>
namespace mbgl {
namespace gfx {
class VertexBufferResource {
protected:
VertexBufferResource() = default;
public:
virtual ~VertexBufferResource() = default;
};
// This class has a template argument that we use to specify the vertex type. It is not used by
// the implementation, but serves type checking purposes during build time.
template <class>
class VertexBuffer {
public:
VertexBuffer(const std::size_t elements_, std::unique_ptr<VertexBufferResource>&& resource_)
: elements(elements_), resource(std::move(resource_)) {
}
std::size_t elements;
template <typename T = VertexBufferResource>
T& getResource() const {
assert(resource);
return static_cast<T&>(*resource);
}
protected:
std::unique_ptr<VertexBufferResource> resource;
};
} // namespace gfx
} // namespace mbgl
|