MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
vertex_buffer.h
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#ifndef OGL_VERTEX_BUFFER_HEADER
11#define OGL_VERTEX_BUFFER_HEADER
12
13#include <memory>
14
15#include "ogl/defines.h"
16#include "ogl/opengl.h"
17#include "ogl/check_gl_error.h"
18
20
31{
32public:
33 typedef std::shared_ptr<VertexBuffer> Ptr;
34 typedef std::shared_ptr<VertexBuffer const> ConstPtr;
35
36public:
37 ~VertexBuffer (void);
38 static Ptr create (void);
39
44 void set_usage (GLenum usage);
45
50 void set_stride (GLsizei stride);
51
53 void set_data (GLfloat const* data, GLsizei elems, GLint vpv);
55 void set_data (GLubyte const* data, GLsizei elems, GLint vpv);
57 void set_indices (GLuint const* data, GLsizei num_indices);
58
60 GLenum get_vbo_target (void) const;
62 GLenum get_data_type (void) const;
64 GLenum get_vbo_usage (void) const;
66 GLsizeiptr get_byte_size (void) const;
68 GLint get_values_per_vertex (void) const;
70 GLsizei get_element_amount (void) const;
72 GLsizei get_stride (void) const;
73
75 void bind (void);
76
77private:
78 VertexBuffer (void);
79
80private:
81 GLuint vbo_id;
82 GLenum vbo_target;
83 GLenum datatype;
84 GLenum usage;
85 GLsizeiptr bytes;
86 GLint vpv;
87 GLsizei elems;
88 GLsizei stride;
89};
90
91/* ---------------------------------------------------------------- */
92
93inline
94VertexBuffer::~VertexBuffer (void)
95{
96 glDeleteBuffers(1, &this->vbo_id);
98}
99
101VertexBuffer::create (void)
102{
103 return Ptr(new VertexBuffer);
104}
105
106inline void
107VertexBuffer::set_stride (GLsizei stride)
108{
109 this->stride = stride;
110}
111
112inline void
113VertexBuffer::set_usage (GLenum usage)
114{
115 this->usage = usage;
116}
117
118inline GLenum
119VertexBuffer::get_vbo_target (void) const
120{
121 return this->vbo_target;
122}
123
124inline GLsizei
125VertexBuffer::get_stride (void) const
126{
127 return this->stride;
128}
129
130inline GLint
131VertexBuffer::get_values_per_vertex (void) const
132{
133 return this->vpv;
134}
135
136inline GLsizeiptr
137VertexBuffer::get_byte_size (void) const
138{
139 return this->bytes;
140}
141
142inline GLsizei
143VertexBuffer::get_element_amount (void) const
144{
145 return this->elems;
146}
147
148inline GLenum
149VertexBuffer::get_vbo_usage (void) const
150{
151 return this->usage;
152}
153
154inline GLenum
155VertexBuffer::get_data_type (void) const
156{
157 return this->datatype;
158}
159
160inline void
161VertexBuffer::bind (void)
162{
163 glBindBuffer(this->vbo_target, this->vbo_id);
164}
165
167
168#endif /* OGL_VERTEX_BUFFER_HEADER */
OpenGL vertex buffer object (VBO) abstraction.
std::shared_ptr< VertexBuffer > Ptr
std::shared_ptr< VertexBuffer const > ConstPtr
void check_gl_error()
#define OGL_NAMESPACE_END
Definition defines.h:14
#define OGL_NAMESPACE_BEGIN
Definition defines.h:13