-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathetexturecollection.cpp
executable file
·41 lines (33 loc) · 1.1 KB
/
etexturecollection.cpp
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
#include "etexturecollection.h"
eTextureCollection::eTextureCollection(SDL_Renderer* const r) :
mRenderer(r) {
}
void eTextureCollection::draw(ePainter& p,
const int x, const int y,
const int id) const {
p.drawTexture(x, y, mTexs[id]);
}
void eTextureCollection::draw(ePainter& p,
const int x, const int y,
const int id,
const eAlignment align) const {
p.drawTexture(x, y, mTexs[id], align);
}
std::shared_ptr<eTexture>& eTextureCollection::addTexture() {
return mTexs.emplace_back(std::make_shared<eTexture>());
}
std::shared_ptr<eTexture> eTextureCollection::loadTexture(
const std::string& path) {
const auto t = std::make_shared<eTexture>();
const bool r = t->load(mRenderer, path);
if(!r) return nullptr;
mTexs.push_back(t);
return mTexs.back();
}
const std::shared_ptr<eTexture>&
eTextureCollection::getTexture(const int id) const {
return mTexs[id];
}
int eTextureCollection::size() const {
return mTexs.size();
}