-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvbo.hpp
80 lines (64 loc) · 2.14 KB
/
vbo.hpp
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef VBO_HPP
#define VBO_HPP
#include "gl_object.hpp"
#include "bindable.hpp"
#include <string>
namespace plush {
/**
* A Vertex Buffer Object (holds data in OpenGL memory).
*/
class VBO : public GLObject, public GLBindable {
protected:
GLenum m_target;
GLenum m_usage;
public:
/**
* Constructor.
*
* @arg target OpenGL target slot to bind the buffer object to (when bind() is called).
* @arg usage Usage pattern (e.g. GL_STATIC_DRAW, GL_DYNAMIC_READ, ...)
*/
VBO(GLenum target, GLenum usage);
~VBO();
void bind();
void unbind();
/**
* Binds the buffer object to its target, resizes it as requested,
* and fills it with data (if @a src is not null).
*
* The VBO stays bound after the call returns.
*/
void data(size_t byteSize, const void* src);
};
/**
* A vertex buffer object that binds to the GL_ARRAY_BUFFER target.
* Used for all kinds of vertex attribute arrays.
*/
class ArrayBuffer : public VBO {
public:
ArrayBuffer(GLenum usage);
/**
* Binds the array buffer and establishes a link between
* the buffer contents and the given vertex attribute
* (using the current shader program).
*
* The buffer stays bound after the call returns.
* It can be unbound any time without affecting the link between
* the buffer and the attribute.
*/
void vertexAttribPointer(const std::string &attribName,
unsigned int valueCount, GLenum valueType,
bool normalize,
int stride, int offset);
};
typedef ArrayBuffer VertexAttribBuffer;
/**
* A vertex buffer object that binds to the GL_ELEMENT_ARRAY_BUFFER target.
* Used for indices into vertex arrays.
*/
class ElementArrayBuffer : public VBO {
public:
ElementArrayBuffer(GLenum usage);
};
}
#endif