| globjects 1.0.0.000000000000 Strict OpenGL objects wrapper.

Buffer.h
Go to the documentation of this file.
1
2 #pragma once
3
4 #include <vector>
5 #include <array>
6
7 #include <glbinding/gl/types.h>
8
9 #include <globjects/globjects_api.h>
10 #include <globjects/Object.h>
11
12
13 namespace globjects
14 {
15
16
35 class GLOBJECTS_API Buffer : public Object
36 {
37 public:
38 enum class BindlessImplementation
39 {
40 DirectStateAccessARB
41 , DirectStateAccessEXT
42 , Legacy
43 };
44
45 static void hintBindlessImplementation(BindlessImplementation impl);
46
52 static void setWorkingTarget(gl::GLenum target);
53
54 public:
57 Buffer();
58
64 static Buffer * fromId(gl::GLuint id);
65
69 virtual void accept(ObjectVisitor & visitor) override;
70
75 void bind(gl::GLenum target) const;
76
80 static void unbind(gl::GLenum target);
81
86 static void unbind(gl::GLenum target, gl::GLuint index);
87
95 void setData(gl::GLsizeiptr size, const gl::GLvoid * data, gl::GLenum usage);
96
99 template <typename T>
100 void setData(const T & data, gl::GLenum usage);
101
104 template <typename T>
105 void setData(const std::vector<T> & data, gl::GLenum usage);
106
109 template <typename T, std::size_t Count>
110 void setData(const std::array<T, Count> & data, gl::GLenum usage);
111
119 void setSubData(gl::GLintptr offset, gl::GLsizeiptr size, const gl::GLvoid* data = nullptr);
120
123 template <typename T>
124 void setSubData(const T & data, gl::GLintptr offset = 0);
125
128 template <typename T>
129 void setSubData(const std::vector<T> & data, gl::GLintptr offset = 0);
130
133 template <typename T, std::size_t Count>
134 void setSubData(const std::array<T, Count> & data, gl::GLintptr offset = 0);
135
142 void setStorage(gl::GLsizeiptr size, const gl::GLvoid * data, gl::BufferStorageMask flags);
143
146 template <typename T>
147 void setStorage(const T & data, gl::BufferStorageMask flags);
148
151 template <typename T>
152 void setStorage(const std::vector<T> & data, gl::BufferStorageMask flags);
153
156 template <typename T, std::size_t Count>
157 void setStorage(const std::array<T, Count> & data, gl::BufferStorageMask flags);
158
165 gl::GLint getParameter(gl::GLenum pname) const;
166
173 gl::GLint64 getParameter64(gl::GLenum pname) const;
174
178 const void * map() const;
179
184 void * map(gl::GLenum access);
185
194 void * mapRange(gl::GLintptr offset, gl::GLsizeiptr length, gl::BufferAccessMask access);
195
199 bool unmap() const;
200
206 void flushMappedRange(gl::GLintptr offset, gl::GLsizeiptr length);
207
211 void bindBase(gl::GLenum target, gl::GLuint index) const;
212
216 void bindRange(gl::GLenum target, gl::GLuint index, gl::GLintptr offset, gl::GLsizeiptr size) const;
217
224 void copySubData(Buffer * buffer, gl::GLintptr readOffset, gl::GLintptr writeOffset, gl::GLsizeiptr size) const;
225
228 void copySubData(Buffer * buffer, gl::GLsizeiptr size) const;
229
236 void copyData(Buffer * buffer, gl::GLsizeiptr size, gl::GLenum usage) const;
237
243 void clearData(gl::GLenum internalformat, gl::GLenum format, gl::GLenum type, const void * data = nullptr);
244
250 void clearSubData(gl::GLenum internalformat, gl::GLintptr offset, gl::GLsizeiptr size, gl::GLenum format, gl::GLenum type, const void * data = nullptr);
251
252 const void * getPointer() const;
253 void * getPointer();
254 const void * getPointer(gl::GLenum pname) const;
255 void * getPointer(gl::GLenum pname);
256
264 void getSubData(gl::GLintptr offset, gl::GLsizeiptr size, void * data) const;
265
268 template <typename T>
269 std::vector<T> getSubData(gl::GLsizeiptr count, gl::GLintptr offset = 0) const;
270
273 template <typename T, std::size_t Count>
274 std::array<T, Count> getSubData(gl::GLintptr offset = 0) const;
275
279 void invalidateData() const;
280
286 void invalidateSubData(gl::GLintptr offset, gl::GLsizeiptr length) const;
287
288 virtual gl::GLenum objectType() const override;
289
290 protected:
294 Buffer(IDResource * resource);
295
299 virtual ~Buffer();
300 };
301
302
303 } // namespace globjects
304
305
306 #include <globjects/Buffer.inl>
globjects::Buffer::BindlessImplementation
BindlessImplementation
Definition: Buffer.h:38
globjects
Contains all the classes that wrap OpenGL functionality.
globjects::Object
Superclass of all wrapped OpenGL objects.
Definition: Object.h:26
globjects::Buffer
Wrapper for OpenGL buffer objects.
Definition: Buffer.h:35
globjects::ObjectVisitor
Implements a Visitor Pattern to iterate over all tracked globjects objects.
Definition: ObjectVisitor.h:29
Object.h