forked from WenlinMao/SleepWalking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavePointObject.cpp
More file actions
42 lines (34 loc) · 1.16 KB
/
Copy pathSavePointObject.cpp
File metadata and controls
42 lines (34 loc) · 1.16 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
#include "SavePointObject.hpp"
SavePointObject::SavePointObject() {
}
SavePointObject::SavePointObject(float mass /* = 10.0f */, const glm::vec3& pos /* = glm::vec3(0.f) */, float w /* = 1.0f */, float h /* = 1.f */, const glm::vec3& vel /* = glm::vec3(0.f) */, bool isFixed /* = false */, const std::string& filename /* = "" */, float l /* = 100.f */)
: GameObject(mass, pos, vel, isFixed, filename, l), width(w), height(h) {
createVerts();
prepareDraw();
}
SavePointObject::~SavePointObject()
{
glDeleteBuffers(1, &VBO_positions);
glDeleteBuffers(1, &EBO);
glDeleteVertexArrays(1, &VAO);
}
void SavePointObject::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 SavePointObject::reset() {
GameObject::reset();
vertex_positions.clear();
}