-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointCloud.cpp
More file actions
49 lines (38 loc) · 1.01 KB
/
PointCloud.cpp
File metadata and controls
49 lines (38 loc) · 1.01 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
#include "PointCloud.h"
PointCloud::PointCloud()
{
}
PointCloud::~PointCloud()
{
// IMPLEMENT ME - free gpu resources for VAO,etc
}
void PointCloud::upload()
{
//printf("PointCloud::upload\n");
vao.bind();
// Upload vertex positions
vbo.bind( GL_ARRAY_BUFFER);
GLsizeiptr vsize = vertices.size() * sizeof(vertices[0]);
// allocate some space for all of our attributes
glBufferData( GL_ARRAY_BUFFER, vsize, NULL, GL_STATIC_DRAW);
// upload positions
glBufferSubData( GL_ARRAY_BUFFER, 0, vsize, &vertices[0]);
GL_WARN_IF_ERROR();
glVertexAttribPointer( POSITION_ATTRIB_INDEX, 4, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray( POSITION_ATTRIB_INDEX);
numVertices = vertices.size();
is_uploaded = true;
}
void PointCloud::bind()
{
vao.bind();
}
void PointCloud::draw()
{
if( vao) {
// Enable gl_PointSize in VS
glEnable( GL_PROGRAM_POINT_SIZE);
glDrawArrays( GL_POINTS, 0, numVertices);
GL_WARN_IF_ERROR();
}
}