SimpleGL  1.1.0
A framework for platform independent rendering
vertex_buffer_object.hpp
Go to the documentation of this file.
1 
8 #ifndef VERTEX_BUFFER_OBJECT_HPP
9 #define VERTEX_BUFFER_OBJECT_HPP
10 
11 #include <SimpleGL_gl/SimpleGL_gl_Export.h>
12 
13 #include <vector>
14 
15 #include <GL/glew.h>
16 
17 #include <glm/glm.hpp>
18 
19 namespace sgl {
20 
26  enum class BufferTarget : GLenum {
27 
29  ARRAY_BUFFER = GL_ARRAY_BUFFER,
30 
32  ELEMENT_ARRAY_BUFFER = GL_ELEMENT_ARRAY_BUFFER
33  };
34 
40  enum class BufferUsage : GLenum {
41 
43  STATIC_DRAW = GL_STATIC_DRAW,
44 
46  STATIC_READ = GL_STATIC_READ,
47 
49  STATIC_COPY = GL_STATIC_COPY,
50 
52  DYNAMIC_DRAW = GL_DYNAMIC_DRAW,
53 
55  DYNAMIC_READ = GL_DYNAMIC_READ,
56 
58  DYNAMIC_COPY = GL_DYNAMIC_COPY,
59 
61  STREAM_DRAW = GL_STREAM_DRAW,
62 
64  STREAM_READ = GL_STREAM_READ,
65 
67  STREAM_COPY = GL_STREAM_COPY
68  };
69 
75  enum class MapAccess : GLenum {
76 
78  READ_ONLY = GL_READ_ONLY,
79 
81  WRITE_ONLY = GL_WRITE_ONLY,
82 
84  READ_WRITE = GL_READ_WRITE
85  };
86 
92  enum class MapRangeAccess : GLbitfield {
93 
95  MAP_READ_BIT = GL_MAP_READ_BIT,
96 
98  MAP_WRITE_BIT = GL_MAP_WRITE_BIT
99  };
100 
106  class SIMPLEGL_GL_EXPORT Buffer {
107 
108  private:
110  static Buffer* current;
111 
113  GLuint handle;
114 
115  public:
117  Buffer(void);
118 
120  ~Buffer(void);
121 
127  GLuint getHandle();
128 
134  void bind(BufferTarget target);
135 
144  void uploadData(BufferTarget target, long size, float* data, BufferUsage usage);
145 
154  void uploadData(BufferTarget target, long size, std::vector<float> data, BufferUsage usage);
155 
164  void uploadData(BufferTarget target, long size, std::vector<glm::vec2> data, BufferUsage usage);
165 
174  void uploadData(BufferTarget target, long size, std::vector<glm::vec3> data, BufferUsage usage);
175 
184  void uploadData(BufferTarget target, long size, std::vector<glm::vec4> data, BufferUsage usage);
185 
193  void uploadData(BufferTarget target, long size, BufferUsage usage);
194 
203  void uploadSubData(BufferTarget target, long offset, long size, float* data);
204 
213  void uploadSubData(BufferTarget target, long offset, long size, std::vector<float> data);
214 
223  void uploadSubData(BufferTarget target, long offset, long size, std::vector<glm::vec2> data);
224 
233  void uploadSubData(BufferTarget target, long offset, long size, std::vector<glm::vec3> data);
234 
243  void uploadSubData(BufferTarget target, long offset, long size, std::vector<glm::vec4> data);
244 
253  void* map(BufferTarget target, MapAccess access);
254 
265  void* mapRange(BufferTarget target, long offset, long length, MapRangeAccess access);
266 
272  void unmap(BufferTarget target);
273  };
274 }
275 
276 #endif /* VERTEX_BUFFER_OBJECT_HPP */
Equivalent to GL_STATIC_DRAW.
Equivalent to GL_ARRAY_BUFFER.
Equivalent to GL_STATIC_COPY.
BufferUsage
This enum wraps the buffer object&#39;s usages.
Equivalent to GL_DYNAMIC_READ.
Equivalent to GL_READ_ONLY.
MapRangeAccess
This enum wraps the buffer object&#39;s map range access bits.
Equivalent to GL_ELEMENT_ARRAY_BUFFER.
Equivalent to GL_MAP_READ_BIT.
Equivalent to GL_STATIC_READ.
This class wraps an OpenGL buffer object.
Generic namespace for the SimpleGL framework.
Definition: application.hpp:18
Equivalent to GL_WRITE_ONLY.
MapAccess
This enum wraps the buffer object&#39;s map accesses.
Equivalent to GL_STREAM_READ.
Equivalent to GL_DYNAMIC_DRAW.
Equivalent to GL_STREAM_DRAW.
Equivalent to GL_STREAM_COPY.
BufferTarget
This enum wraps the buffer object&#39;s targets.
Equivalent to GL_READ_WRITE.
Equivalent to GL_DYNAMIC_COPY.
Equivalent to GL_MAP_WRITE_BIT.