MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
vertex_buffer.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 */
9
10#include "ogl/vertex_buffer.h"
11
13
14VertexBuffer::VertexBuffer (void)
15{
16 glGenBuffers(1, &this->vbo_id);
18 this->vbo_target = GL_ARRAY_BUFFER;
19 this->datatype = GL_FLOAT;
20 this->usage = GL_STATIC_DRAW;
21 this->bytes = 0;
22 this->vpv = 0;
23 this->elems = 0;
24 this->stride = 0;
25}
26
27/* ---------------------------------------------------------------- */
28
29void
30VertexBuffer::set_data (GLfloat const* data, GLsizei elems, GLint vpv)
31{
32 this->vbo_target = GL_ARRAY_BUFFER;
33 this->datatype = GL_FLOAT;
34 this->bytes = elems * vpv * sizeof(GLfloat);
35 this->vpv = vpv;
36 this->elems = elems;
37
38 this->bind();
39 glBufferData(this->vbo_target, this->bytes, data, this->usage);
41}
42
43/* ---------------------------------------------------------------- */
44
45void
46VertexBuffer::set_data (GLubyte const* data, GLsizei elems, GLint vpv)
47{
48 this->vbo_target = GL_ARRAY_BUFFER;
49 this->datatype = GL_UNSIGNED_BYTE;
50 this->bytes = elems * vpv * sizeof(GLubyte);
51 this->vpv = vpv;
52 this->elems = elems;
53
54 this->bind();
55 glBufferData(this->vbo_target, this->bytes, data, this->usage);
57}
58
59/* ---------------------------------------------------------------- */
60
61void
62VertexBuffer::set_indices (GLuint const* data, GLsizei num_indices)
63{
64 this->vbo_target = GL_ELEMENT_ARRAY_BUFFER;
65 this->datatype = GL_UNSIGNED_INT;
66 this->bytes = num_indices * sizeof(unsigned int);
67 this->vpv = 3;
68 this->elems = num_indices;
69
70 this->bind();
71 glBufferData(this->vbo_target, this->bytes, data, this->usage);
73}
74
void check_gl_error()
#define OGL_NAMESPACE_END
Definition defines.h:14
#define OGL_NAMESPACE_BEGIN
Definition defines.h:13