-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawable.cpp
More file actions
28 lines (23 loc) · 787 Bytes
/
Drawable.cpp
File metadata and controls
28 lines (23 loc) · 787 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
27
28
#include "Drawable.h"
#include "GraphicsMacros.h"
#include "IndexBuffer.h"
#include <assert.h>
#include <typeinfo>
void Drawable::Draw(Graphics& gfx) const noexcept(!IS_DEBUG) {
for (auto& bind : binds) {
bind->Bind(gfx);
}
for (auto& bind : GetStaticBinds()) {
bind->Bind(gfx);
}
gfx.DrawIndexed(pIndexBuffer->GetCount());
}
void Drawable::AddBind(std::unique_ptr<Bindable> bind) noexcept(!IS_DEBUG) {
assert("Must only use AddIndexBuffer() to bind an index buffer" && typeid(*bind) != typeid(IndexBuffer));
binds.push_back(std::move(bind));
}
void Drawable::AddIndexBuffer(std::unique_ptr<IndexBuffer> ibuf) noexcept(!IS_DEBUG) {
assert("Index Buffer has already been added" && pIndexBuffer == nullptr);
pIndexBuffer = ibuf.get();
binds.push_back(std::move(ibuf));
}