-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawable.cpp
More file actions
26 lines (23 loc) · 765 Bytes
/
Drawable.cpp
File metadata and controls
26 lines (23 loc) · 765 Bytes
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
#include "Drawable.h"
#include "GraphicsMacros.h"
#include "IndexBuffer.h"
#include <cassert>
#include <typeinfo>
void Drawable::draw(Graphics& g) const noexcept(!IS_DEBUG) {
for (auto& b : binds) {
b->bind(g);
}
for (auto& b : getStaticBinds()) {
b->bind(g);
}
g.drawIndexed(pIndexBuffer->getCount());
}
void Drawable::addBind(std::unique_ptr<Bindable> bind) noexcept(!IS_DEBUG) {
assert(typeid(*bind) != typeid(IndexBuffer) && "Must use addIndexBuffer() to bind index buffer");
binds.push_back(std::move(bind));
}
void Drawable::addIndexBuffer(std::unique_ptr<IndexBuffer> ibuf) noexcept(!IS_DEBUG) {
assert(pIndexBuffer == nullptr && "Attempting to add index buffer a second time");
pIndexBuffer = ibuf.get();
binds.push_back(std::move(ibuf));
}