13 #ifndef OGLPLUS_DSA_BUFFER_MAP_1309301821_HPP
14 #define OGLPLUS_DSA_BUFFER_MAP_1309301821_HPP
20 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_5 || GL_ARB_direct_state_access
25 const GLintptr _offset;
30 static GLsizeiptr _get_size(GLuint name)
33 OGLPLUS_GLFUNC(GetNamedBufferParameteriv)(
39 GetNamedBufferParameteriv,
41 Object(BufferName(name))
43 return GLsizeiptr(value);
46 static GLenum _translate(GLbitfield access)
52 case GL_MAP_WRITE_BIT:
54 case GL_MAP_READ_BIT|GL_MAP_WRITE_BIT:
73 Bitfield<BufferMapAccess> access
74 ): _offset(GLintptr(offset.Get()))
75 , _size(GLsizeiptr(size.Get()))
77 OGLPLUS_GLFUNC(MapNamedBufferRange)(
103 Bitfield<BufferMapAccess> access
107 OGLPLUS_GLFUNC(MapNamedBuffer)(
109 _translate(GLbitfield(access))
120 #if !OGLPLUS_NO_DELETED_FUNCTIONS
121 DSABufferRawMap(
const DSABufferRawMap&) =
delete;
124 DSABufferRawMap(
const DSABufferRawMap&);
129 DSABufferRawMap(DSABufferRawMap&& temp)
130 : _offset(temp._offset)
138 ~DSABufferRawMap(
void)
155 OGLPLUS_GLFUNC(UnmapNamedBuffer)(_name);
156 OGLPLUS_IGNORE(UnmapNamedBuffer);
162 bool Mapped(
void)
const
164 return _ptr !=
nullptr;
168 GLsizeiptr Size(
void)
const
177 const GLvoid* RawData(
void)
const
187 GLvoid* RawData(
void)
202 void FlushRange(BufferSize offset, BufferSize length)
204 OGLPLUS_GLFUNC(FlushMappedNamedBufferRange)(
206 GLintptr(offset.Get()),
207 GLsizeiptr(length.Get())
210 FlushMappedNamedBufferRange,
212 Object(BufferName(_name))
218 template <
typename Type>
220 :
public DSABufferRawMap
234 BufferTypedSize<Type> offset,
235 BufferTypedSize<Type> size,
237 ): DSABufferRawMap(buffer, offset, size, access)
252 ): DSABufferRawMap(buffer, access)
257 : DSABufferRawMap(static_cast<DSABufferRawMap&&>(temp))
263 assert(this->Size() %
sizeof(Type) == 0);
264 return this->Size() /
sizeof(Type);
270 return static_cast<const Type*
>(this->RawData());
276 return static_cast<Type*
>(this->RawData());
280 const Type&
At(GLuint index)
const
282 assert(
Data() !=
nullptr);
283 assert(((index+1)*
sizeof(Type)) <= std::size_t(this->Size()));
284 return Data()[index];
288 Type&
At(GLuint index)
290 assert(
Data() !=
nullptr);
291 assert(((index+1)*
sizeof(Type)) <= std::size_t(this->Size()));
292 return Data()[index];
296 #endif // GL_ARB_direct_state_access
300 #endif // include guard
DSABufferTypedMap(BufferName buffer, BufferTypedSize< Type > offset, BufferTypedSize< Type > size, Bitfield< BufferMapAccess > access)
Maps a range of the buffer.
Definition: buffer_map.hpp:232
DSABufferTypedMap(BufferName buffer, Bitfield< BufferMapAccess > access)
Maps the whole buffer.
Definition: buffer_map.hpp:249
Untyped mapping of the buffer to the client address space.
Definition: buffer_map.hpp:219
GLsizeiptr Count(void) const
Returns the count of elements of Type in the mapped buffer.
Definition: buffer_map.hpp:261
This template serves as a wrapper for OpenGL bitfields.
Definition: bitfield.hpp:56
const Type & At(GLuint index) const
Returns a const reference to the element at the specified index.
Definition: buffer_map.hpp:280
GLuint GetGLName(ObjectName< ObjTag > named)
Returns the GLuint OpenGL name assigned to named object.
Definition: name.hpp:38
DSABufferTypedMap(DSABufferTypedMap &&temp)
Move construction is enabled.
Definition: buffer_map.hpp:256
const Type * Data(void) const
Returns a const pointer to the mapped data.
Definition: buffer_map.hpp:268
Type * Data(void)
Returns a pointer to the mapped data.
Definition: buffer_map.hpp:274
Type & At(GLuint index)
Returns a reference to the element at the specified index.
Definition: buffer_map.hpp:288
A common template for "named" objects like textures, buffers, etc.
Definition: fwd.hpp:136