forked from WenlinMao/SleepWalking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIBGObject.cpp
More file actions
49 lines (39 loc) · 1.17 KB
/
Copy pathUIBGObject.cpp
File metadata and controls
49 lines (39 loc) · 1.17 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
/**
* @ Author: Wenlin Mao
* @ Create Time: 2021-10-30 18:35:37
* @ Modified by: Wenlin Mao
* @ Modified time: 2021-11-29 17:47:10
* @ Description: implementation of square object
*/
#include "UIBGObject.hpp"
#include "Inivar.hpp"
#include "PlayerStats.hpp"
UIBGObject::UIBGObject(){
}
UIBGObject::UIBGObject(const glm::vec3& pos, float w, float h,
const std::string& filename):
UIObject(10.f, pos, filename),
width(w), height(h){
createVerts();
prepareDraw();
}
UIBGObject::~UIBGObject(){}
void UIBGObject::createVerts(){
vertex_positions = vector<glm::vec4>({
glm::vec4(width/2.f, height/2, 0.0f, 1.0f), // top right
glm::vec4(width/2.f, -height/2, 0.0f, 1.0f), // bottom right
glm::vec4(-width/2.f, -height/2, 0.0f, 1.0f), // bottom left
glm::vec4(-width/2.f, height/2, 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 UIBGObject::reset(){
GameObject::reset();
vertex_positions.clear();
}