13 #ifndef OGLPLUS_BUFFER_MAP_1107121519_HPP
14 #define OGLPLUS_BUFFER_MAP_1107121519_HPP
24 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_0
29 const GLintptr _offset;
37 OGLPLUS_GLFUNC(GetBufferParameteriv)(
47 return GLsizeiptr(value);
50 static GLenum _translate(GLbitfield access)
56 case GL_MAP_WRITE_BIT:
58 case GL_MAP_READ_BIT|GL_MAP_WRITE_BIT:
81 ): _offset(GLintptr(byte_offset.Get()))
82 , _size(GLsizeiptr(size_bytes.Get()))
84 OGLPLUS_GLFUNC(MapBufferRange)(
113 , _size(_get_size(target))
115 OGLPLUS_GLFUNC(MapBuffer)(
117 _translate(GLbitfield(access))
124 ObjectBinding(_target)
128 #if !OGLPLUS_NO_DELETED_FUNCTIONS
137 : _offset(temp._offset)
140 , _target(temp._target)
163 OGLPLUS_GLFUNC(UnmapBuffer)(GLenum(_target));
167 ObjectBinding(_target)
176 return _ptr !=
nullptr;
216 OGLPLUS_GLFUNC(FlushMappedBufferRange)(
218 GLintptr(offset.
Get()),
219 GLsizeiptr(length.
Get())
222 FlushMappedBufferRange,
224 ObjectBinding(_target)
230 template <
typename Type>
246 BufferTypedSize<Type> offset,
247 BufferTypedSize<Type> size,
273 assert(this->
Size() %
sizeof(Type) == 0);
274 return this->
Size() /
sizeof(Type);
280 return static_cast<const Type*
>(this->
RawData());
286 return static_cast<Type*
>(this->
RawData());
290 const Type&
At(GLuint index)
const
292 assert(
Data() !=
nullptr);
293 assert(((index+1)*
sizeof(Type)) <= std::size_t(this->
Size()));
294 return Data()[index];
298 Type&
At(GLuint index)
300 assert(
Data() !=
nullptr);
301 assert(((index+1)*
sizeof(Type)) <= std::size_t(this->
Size()));
302 return Data()[index];
318 BufferTypedSize<Type> start,
319 BufferTypedSize<Type> count
325 #endif // GL_VERSION_3_0
329 #endif // include guard
BufferTypedMap(BufferTarget target, BufferTypedSize< Type > offset, BufferTypedSize< Type > size, Bitfield< BufferMapAccess > access)
Maps a range of the buffer.
Definition: buffer_map.hpp:244
BufferTypedMap(BufferTarget target, Bitfield< BufferMapAccess > access)
Maps the whole buffer.
Definition: buffer_map.hpp:261
Type * Data(void)
Returns a pointer to the mapped data.
Definition: buffer_map.hpp:284
bool Mapped(void) const
Returns true if the buffer is mapped.
Definition: buffer_map.hpp:174
GLsizeiptr Count(void) const
Returns the count of elements of Type in the mapped buffer.
Definition: buffer_map.hpp:271
Buffer bind target enumerations.
This class represents the size of a GPU buffer in bytes.
Definition: buffer_size.hpp:22
Typed mapping of the buffer to the client address space.
Definition: buffer_map.hpp:231
Declaration of OGLplus object-related error.
const Type & At(GLuint index) const
Returns a const reference to the element at the specified index.
Definition: buffer_map.hpp:290
Buffer map access enumeration/bitfield.
GLsizeiptr Size(void) const
Returns the size (in bytes) of the mapped buffer.
Definition: buffer_map.hpp:180
This template serves as a wrapper for OpenGL bitfields.
Definition: bitfield.hpp:56
BufferTypedMap(BufferTypedMap &&temp)
Move construction is enabled.
Definition: buffer_map.hpp:266
Object representing Buffer's storage size in bytes.
BufferRawMap(BufferTarget target, Bitfield< BufferMapAccess > access)
Maps the whole buffer.
Definition: buffer_map.hpp:111
BufferRawMap(BufferTarget target, BufferSize byte_offset, BufferSize size_bytes, Bitfield< BufferMapAccess > access)
Maps a range of the buffer.
Definition: buffer_map.hpp:76
const Type * Data(void) const
Returns a const pointer to the mapped data.
Definition: buffer_map.hpp:278
GLvoid * RawData(void)
Returns a pointer to the mapped data.
Definition: buffer_map.hpp:199
void Unmap(void)
Unmaps the buffer from client address space.
Definition: buffer_map.hpp:159
Helper macro for optional checking of availability of GL function.
~BufferRawMap(void)
Unmaps the buffer from client address space (if mapped)
Definition: buffer_map.hpp:146
Type & At(GLuint index)
Returns a reference to the element at the specified index.
Definition: buffer_map.hpp:298
GLsizeiptr Get(void) const
Gets the size in bytes.
Definition: buffer_size.hpp:58
Exception class for general OpenGL errors.
Definition: basic.hpp:43
Exception class for GL object-related errors.
Definition: object.hpp:24
void FlushElements(BufferTypedSize< Type > start, BufferTypedSize< Type > count)
Indicate modifications to a mapped range of elements of Type.
Definition: buffer_map.hpp:317
void FlushRange(BufferSize offset, BufferSize length)
Indicate modifications to a mapped range.
Definition: buffer_map.hpp:214
Untyped mapping of the buffer to the client address space.
Definition: buffer_map.hpp:26
const GLvoid * RawData(void) const
Returns a const pointer to the mapped data.
Definition: buffer_map.hpp:189
BufferTarget
Buffer bind target.
Definition: buffer_target.hpp:24