forked from WenlinMao/SleepWalking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectableObject.cpp
More file actions
53 lines (42 loc) · 1.51 KB
/
Copy pathCollectableObject.cpp
File metadata and controls
53 lines (42 loc) · 1.51 KB
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
#include "load_save_png.hpp"
#include "data_path.hpp"
#include "CollectableObject.hpp"
#include "Inivar.hpp"
CollectableObject::CollectableObject() {
}
CollectableObject::CollectableObject(float mass, const glm::vec3& pos, float w, float h,
const glm::vec3& vel, bool isFixed, const std::string& filename, float l) :
GameObject(mass, pos, vel, isFixed, filename, l), width(w), height(h) {
createVerts();
prepareDraw();
}
CollectableObject::~CollectableObject() {
//std::cout << "deleting box\n";
//std::cout << "Use Count Prev: " << box.use_count() << std::endl;
box.reset();
//std::cout << "Use Count After: " << box.use_count() << std::endl;
//std::cout << "deleting buffers\n";
glDeleteBuffers(1, &VBO_positions);
glDeleteBuffers(1, &EBO);
glDeleteVertexArrays(1, &VAO);
//std::cout << "finished deletion\n";
}
void CollectableObject::createVerts() {
vertex_positions = vector<glm::vec4>({
glm::vec4(width, height, 0.0f, 1.0f), // top right
glm::vec4(width, -height, 0.0f, 1.0f), // bottom right
glm::vec4(-width, -height, 0.0f, 1.0f), // bottom left
glm::vec4(-width, height, 0.0f, 1.0f) // top left
});
vertex_texcoords = vector<glm::vec2>({
glm::vec2(1.f,1.f),
glm::vec2(1.f,0.f),
glm::vec2(0.f,0.f),
glm::vec2(0.f,1.f)
});
indices = std::vector<unsigned int>({ 0, 1, 2, 2, 3, 0 });
}
void CollectableObject::reset() {
GameObject::reset();
vertex_positions.clear();
}