-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbillboard.cpp
More file actions
35 lines (27 loc) · 798 Bytes
/
billboard.cpp
File metadata and controls
35 lines (27 loc) · 798 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
29
30
31
32
33
34
35
#include "billboard.hpp"
#include "shader.hpp"
using namespace glm;
vec3 vertices[] = {{-1.0f, -1.0f, 0.0f},
{-1.0f, 1.0f, 0.0f},
{ 1.0f, -1.0f, 0.0f},
{ 1.0f, 1.0f, 0.0f}
};
billboard::billboard() {
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindVertexArray(0);
}
billboard::~billboard() {
glDeleteBuffers(1, &vbo);
glDeleteVertexArrays(1, &vao);
}
void billboard::draw() {
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 5);
}