class
#include <Magnum/GL/Buffer.h>
Buffer Buffer.
Wraps an OpenGL buffer object.
Data upload
Data can be uploaded to the buffer with setData(), setSubData() or the shorthand Buffer() constructor. All these functions accept a Containers::
const Vector3 data[]{ … }; GL::Buffer buffer; buffer.setData(data); GL::Buffer buffer2{data}; // or construct & fill in a single step
Furthermore, if you #include
Corrade/
std::vector<Vector3> data = …; buffer.setData(data);
An alternative to setData() that provides more flexibility and better performance guarantees is setStorage(). It's similar in spirit to texture storage, however as it's only available on desktop OpenGL 4.4 ( ARB_
GL::Buffer buffer; buffer.setStorage(data, {});
Memory mapping
Buffer data can be also updated asynchronously. First you need to allocate the buffer to desired size by passing nullptr
to setData(), e.g.:
buffer.setData({nullptr, 200*sizeof(Vector3)});
Then you can map the buffer to client memory and operate with the memory directly. After you are done with the operation, call unmap() to unmap the buffer again. The map() functions return a view on a char
array and you may want to cast it to some useful type first using Containers::
Containers::ArrayView<Vector3> data = Containers::arrayCast<Vector3>( buffer.map(0, 200*sizeof(Vector3), GL::Buffer::MapFlag::Write|GL::Buffer::MapFlag::InvalidateBuffer)); CORRADE_INTERNAL_ASSERT(data); for(Vector3& d: data) d = {/*...*/}; CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap());
If you are updating only a few discrete portions of the buffer, you can use MapFlag::
Containers::ArrayView<Vector3> data = Containers::arrayCast<Vector3>( buffer.map(0, 200*sizeof(Vector3), GL::Buffer::MapFlag::Write|GL::Buffer::MapFlag::FlushExplicit)); CORRADE_INTERNAL_ASSERT(data); for(std::size_t i: {7, 27, 56, 128}) { data[i] = {/*...*/}; buffer.flushMappedRange(i*sizeof(Vector3), sizeof(Vector3)); } CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap());
WebGL restrictions
Buffers in WebGL need to be bound only to one unique target, i.e., Buffer bound to Buffer::
GL::Buffer vertices; GL::Buffer indices;
To avoid GL errors, you have to set target hint to desired target, either in the constructor or using setTargetHint(). A similar care needs to be taken for uniform buffers and other types of buffers.
GL::Buffer vertices{GL::Buffer::TargetHint::Array}; GL::Buffer indices{GL::Buffer::TargetHint::ElementArray};
To simplify debugging, the Mesh class checks proper target hint when adding vertex and index buffers under WebGL.
Performance optimizations
The engine tracks currently bound buffers to avoid unnecessary calls to glBindBuffer(). If the buffer is already bound to some target, functions copy(), setStorage(), setData(), setSubData(), map(), mapRead(), flushMappedRange() and unmap() use that target instead of binding the buffer to some specific target. You can also use setTargetHint() to possibly reduce unnecessary rebinding. Buffer limits and implementation-defined values (such as maxUniformBindings()) are cached, so repeated queries don't result in repeated glGet() calls. See also Context::
If ARB_
You can use functions invalidateData() and invalidateSubData() if you don't need buffer data anymore to avoid unnecessary memory operations performed by OpenGL in order to preserve the data. If running on OpenGL ES or extension ARB_
Base classes
- class AbstractObject
- Base for all OpenGL objects.
Public types
- enum class TargetHint: UnsignedShort { Array = GL_ARRAY_BUFFER, AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, CopyRead = GL_COPY_READ_BUFFER, CopyWrite = GL_COPY_WRITE_BUFFER, DispatchIndirect = GL_DISPATCH_INDIRECT_BUFFER, DrawIndirect = GL_DRAW_INDIRECT_BUFFER, ElementArray = GL_ELEMENT_ARRAY_BUFFER, PixelPack = GL_PIXEL_PACK_BUFFER, PixelUnpack = GL_PIXEL_UNPACK_BUFFER, ShaderStorage = GL_SHADER_STORAGE_BUFFER, Texture = GL_TEXTURE_BUFFER, TransformFeedback = GL_TRANSFORM_FEEDBACK_BUFFER, Uniform = GL_UNIFORM_BUFFER }
- Buffer target.
- enum class Target: GLenum { AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, ShaderStorage = GL_SHADER_STORAGE_BUFFER, Uniform = GL_UNIFORM_BUFFER }
- Buffer binding target.
- enum class MapAccess: GLenum { ReadOnly = GL_READ_ONLY, WriteOnly = GL_WRITE_ONLY, ReadWrite = GL_READ_WRITE }
- Memory mapping access.
- enum class MapFlag: GLbitfield { Read = GL_MAP_READ_BIT, Write = GL_MAP_WRITE_BIT, InvalidateBuffer = GL_MAP_INVALIDATE_BUFFER_BIT, InvalidateRange = GL_MAP_INVALIDATE_RANGE_BIT, FlushExplicit = GL_MAP_FLUSH_EXPLICIT_BIT, Unsynchronized = GL_MAP_UNSYNCHRONIZED_BIT, Persistent = GL_MAP_PERSISTENT_BIT new in Git master, Coherent = GL_MAP_COHERENT_BIT new in Git master }
- Memory mapping flag.
- enum class StorageFlag: GLbitfield { MapRead = GL_MAP_READ_BIT, MapWrite = GL_MAP_WRITE_BIT, MapPersistent = GL_MAP_PERSISTENT_BIT, MapCoherent = GL_MAP_COHERENT_BIT, DynamicStorage = GL_DYNAMIC_STORAGE_BIT, ClientStorage = GL_CLIENT_STORAGE_BIT } new in Git master
- Buffer storage flag.
-
using MapFlags = Containers::
EnumSet<MapFlag> - Memory mapping flags.
-
using StorageFlags = Containers::
EnumSet<StorageFlag> new in Git master - Buffer storage flags.
Public static functions
- static auto minMapAlignment() -> Int
- Minimal supported mapping alignment.
- static auto maxAtomicCounterBindings() -> Int
- Max supported atomic counter buffer binding count.
- static auto maxShaderStorageBindings() -> Int
- Max supported shader storage buffer binding count.
- static auto uniformOffsetAlignment() -> Int
- Alignment of uniform buffer binding offset.
- static auto shaderStorageOffsetAlignment() -> Int
- Alignment of shader storage buffer binding offset.
- static auto maxUniformBindings() -> Int
- Max supported uniform buffer binding count.
- static void unbind(Target target, UnsignedInt index)
- Unbind any buffer from given indexed target.
-
static void unbind(Target target,
UnsignedInt firstIndex,
std::
size_t count) - Unbind given range of indexed targets.
-
static void bind(Target target,
UnsignedInt firstIndex,
Containers::
ArrayView<const Containers:: Triple<Buffer*, GLintptr, GLsizeiptr>> buffers) new in Git master - Bind ranges of buffers to given range of indexed targets.
-
static void bind(Target target,
UnsignedInt firstIndex,
std::
initializer_list<Containers:: Triple<Buffer*, GLintptr, GLsizeiptr>> buffers) new in Git master -
static void bind(Target target,
UnsignedInt firstIndex,
Containers::
ArrayView<Buffer*const> buffers) new in Git master - Bind buffers to given range of indexed targets.
-
static void bind(Target target,
UnsignedInt firstIndex,
std::
initializer_list<Buffer*> buffers) - static void copy(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
- Copy one buffer to another.
-
static auto wrap(GLuint id,
TargetHint targetHint = TargetHint::
Array, ObjectFlags flags = {}) -> Buffer - Wrap existing OpenGL buffer object.
- static auto wrap(GLuint id, ObjectFlags flags) -> Buffer
Constructors, destructors, conversion operators
-
Buffer(TargetHint targetHint = TargetHint::
Array) explicit - Constructor.
- Buffer(NoCreateT) explicit noexcept
- Construct without creating the underlying OpenGL object.
-
Buffer(TargetHint targetHint,
Containers::
ArrayView<const void> data, BufferUsage usage = BufferUsage:: StaticDraw) explicit new in 2020.06 - Construct and directly fill with data.
-
template<class T>Buffer(TargetHint targetHint, std::
initializer_list<T> data, BufferUsage usage = BufferUsage:: StaticDraw) explicit new in 2020.06 -
Buffer(Containers::
ArrayView<const void> data, BufferUsage usage = BufferUsage:: StaticDraw) explicit new in 2020.06 - Buffer(const Buffer&) deleted
- Copying is not allowed.
- Buffer(Buffer&& other) noexcept
- Move constructor.
- ~Buffer()
- Destructor.
Public functions
- auto operator=(const Buffer&) -> Buffer& deleted
- Copying is not allowed.
- auto operator=(Buffer&& other) -> Buffer& noexcept
- Move assignment.
- auto id() const -> GLuint
- OpenGL buffer ID.
- auto release() -> GLuint
- Release OpenGL object.
-
auto label() -> Containers::
String - Buffer label.
-
auto setLabel(Containers::
StringView label) -> Buffer& - Set buffer label.
- auto targetHint() const -> TargetHint
- Target hint.
- auto setTargetHint(TargetHint hint) -> Buffer&
- Set target hint.
- auto bind(Target target, UnsignedInt index, GLintptr offset, GLsizeiptr size) -> Buffer&
- Bind buffer range to given binding index.
- auto bind(Target target, UnsignedInt index) -> Buffer&
- Bind buffer to given binding index.
-
auto setStorage(Containers::
ArrayView<const void> data, StorageFlags flags) -> Buffer& new in Git master - Set storage.
-
auto setStorage(std::
size_t size, StorageFlags flags) -> Buffer& new in Git master - Set storage.
- auto size() -> Int
- Buffer size in bytes.
-
auto data() -> Containers::
Array<char> - Buffer data.
-
auto subData(GLintptr offset,
GLsizeiptr size) -> Containers::
Array<char> - Buffer subdata.
-
auto setData(Containers::
ArrayView<const void> data, BufferUsage usage = BufferUsage:: StaticDraw) -> Buffer& - Set buffer data.
-
template<class T>auto setData(std::
initializer_list<T> data, BufferUsage usage = BufferUsage:: StaticDraw) -> Buffer& new in 2019.10 -
auto setSubData(GLintptr offset,
Containers::
ArrayView<const void> data) -> Buffer& - Set buffer subdata.
-
template<class T>auto setSubData(GLintptr offset, std::
initializer_list<T> data) -> Buffer& new in 2019.10 - auto invalidateData() -> Buffer&
- Invalidate buffer data.
- auto invalidateSubData(GLintptr offset, GLsizeiptr length) -> Buffer&
- Invalidate buffer subdata.
- auto map(MapAccess access) -> char*
- Map buffer to client memory.
- auto mapRead() -> const char*
- Map buffer read-only to client memory.
-
auto map(GLintptr offset,
GLsizeiptr length,
MapFlags flags) -> Containers::
ArrayView<char> - Map buffer to client memory.
-
auto mapRead(GLintptr offset,
GLsizeiptr length,
MapFlags flags = {}) -> Containers::
ArrayView<const char> - Map buffer read-only to client memory.
- auto flushMappedRange(GLintptr offset, GLsizeiptr length) -> Buffer&
- Flush mapped range.
- auto unmap() -> bool
- Unmap buffer.
Enum documentation
enum class Magnum:: GL:: Buffer:: TargetHint: UnsignedShort
Buffer target.
Enumerators | |
---|---|
Array |
Used for storing vertex attributes. |
AtomicCounter |
Used for storing atomic counters. |
CopyRead |
Source for copies. See copy(). |
CopyWrite |
Target for copies. See copy(). |
DispatchIndirect |
Indirect compute dispatch commands. |
DrawIndirect |
Used for supplying arguments for indirect drawing. |
ElementArray |
Used for storing vertex indices. |
PixelPack |
Target for pixel pack operations. |
PixelUnpack |
Source for texture update operations. |
ShaderStorage |
Used for shader storage. |
Texture |
Source for texel fetches. See BufferTexture. |
TransformFeedback |
Target for transform feedback. |
Uniform |
Used for storing uniforms. |
enum class Magnum:: GL:: Buffer:: Target: GLenum
Buffer binding target.
Enumerators | |
---|---|
AtomicCounter |
Atomic counter binding |
ShaderStorage |
Shader storage binding |
Uniform |
Uniform binding |
enum class Magnum:: GL:: Buffer:: MapFlag: GLbitfield
Memory mapping flag.
Enumerators | |
---|---|
Read |
Map buffer for reading. |
Write |
Map buffer for writing. |
InvalidateBuffer |
Previous contents of the entire buffer may be discarded. May not be used in combination with MapFlag:: |
InvalidateRange |
Previous contents of mapped range may be discarded. May not be used in combination with MapFlag:: |
FlushExplicit |
Only one or more discrete subranges of the mapping will be modified. See flushMappedRange() for more information. May only be used in conjunction with MapFlag:: |
Unsynchronized |
No pending operations on the buffer should be synchronized before mapping. |
Persistent new in Git master |
Allow reading from or writing to the buffer while it is mapped. |
Coherent new in Git master |
Shared access to buffer that's both mapped and used will be coherent. |
enum class Magnum:: GL:: Buffer:: StorageFlag: GLbitfield new in Git master
Buffer storage flag.
Enumerators | |
---|---|
MapRead |
Allow the buffer to be mapped with MapFlag:: |
MapWrite |
Allow the buffer to be mapped with MapFlag:: |
MapPersistent |
Allow the buffer to be mapped with MapFlag:: |
MapCoherent |
Allow the buffer to be mapped with MapFlag:: |
DynamicStorage |
Allow the buffer to be updated with setSubData(). Note that the buffer can still be updated through copy() even without this flag present. |
ClientStorage |
Prefer to allocate the memory in client memory space. |
Typedef documentation
typedef Containers:: EnumSet<MapFlag> Magnum:: GL:: Buffer:: MapFlags
Memory mapping flags.
typedef Containers:: EnumSet<StorageFlag> Magnum:: GL:: Buffer:: StorageFlags new in Git master
Buffer storage flags.
Function documentation
static Int Magnum:: GL:: Buffer:: minMapAlignment()
Minimal supported mapping alignment.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_1
.
static Int Magnum:: GL:: Buffer:: maxAtomicCounterBindings()
Max supported atomic counter buffer binding count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: Buffer:: maxShaderStorageBindings()
Max supported shader storage buffer binding count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: Buffer:: uniformOffsetAlignment()
Alignment of uniform buffer binding offset.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_1
.
static Int Magnum:: GL:: Buffer:: shaderStorageOffsetAlignment()
Alignment of shader storage buffer binding offset.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_1
.
static Int Magnum:: GL:: Buffer:: maxUniformBindings()
Max supported uniform buffer binding count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_0
.
static void Magnum:: GL:: Buffer:: unbind(Target target,
UnsignedInt index)
Unbind any buffer from given indexed target.
The index
parameter must respect limits for given target
.
static void Magnum:: GL:: Buffer:: unbind(Target target,
UnsignedInt firstIndex,
std:: size_t count)
Unbind given range of indexed targets.
Unbinds all buffers in given target in range . The range of indices must respect limits for given target
. If ARB_
static void Magnum:: GL:: Buffer:: bind(Target target,
UnsignedInt firstIndex,
Containers:: ArrayView<const Containers:: Triple<Buffer*, GLintptr, GLsizeiptr>> buffers) new in Git master
Bind ranges of buffers to given range of indexed targets.
Binds first buffer in the list to firstIndex
, second to firstIndex + 1
etc. Second parameter is offset, third is size. If any buffer is nullptr
, given indexed target is unbound. The range of indices must respect limits for given target
. The offsets must respect alignment, which is 4 bytes for Target::
static void Magnum:: GL:: Buffer:: bind(Target target,
UnsignedInt firstIndex,
std:: initializer_list<Containers:: Triple<Buffer*, GLintptr, GLsizeiptr>> buffers) new in Git master
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static void Magnum:: GL:: Buffer:: bind(Target target,
UnsignedInt firstIndex,
Containers:: ArrayView<Buffer*const> buffers) new in Git master
Bind buffers to given range of indexed targets.
Binds first buffer in the list to firstIndex
, second to firstIndex + 1
etc. If any buffer is nullptr
, given indexed target is unbound. The range of indices must respect limits for given target
. All the buffers must have allocated data store. If ARB_
static void Magnum:: GL:: Buffer:: bind(Target target,
UnsignedInt firstIndex,
std:: initializer_list<Buffer*> buffers)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static void Magnum:: GL:: Buffer:: copy(Buffer& read,
Buffer& write,
GLintptr readOffset,
GLintptr writeOffset,
GLsizeiptr size)
Copy one buffer to another.
Parameters | |
---|---|
read | Buffer from which to read |
write | Buffer to which to copy |
readOffset | Offset in the read buffer |
writeOffset | Offset in the write buffer |
size | Data size |
If ARB_read
buffer is bound for reading and write
buffer is bound for writing before the copy is performed (if not already).
static Buffer Magnum:: GL:: Buffer:: wrap(GLuint id,
TargetHint targetHint = TargetHint:: Array,
ObjectFlags flags = {})
Wrap existing OpenGL buffer object.
Parameters | |
---|---|
id | OpenGL buffer ID |
targetHint | Target hint, see setTargetHint() for more information |
flags | Object creation flags |
The id
is expected to be of an existing OpenGL buffer object. Unlike buffer created using constructor, the OpenGL object is by default not deleted on destruction, use flags
for different behavior.
static Buffer Magnum:: GL:: Buffer:: wrap(GLuint id,
ObjectFlags flags)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Magnum:: GL:: Buffer:: Buffer(TargetHint targetHint = TargetHint:: Array) explicit
Constructor.
Parameters | |
---|---|
targetHint | Target hint, see setTargetHint() for more information |
Creates new OpenGL buffer object. If ARB_
Magnum:: GL:: Buffer:: Buffer(NoCreateT) explicit noexcept
Construct without creating the underlying OpenGL object.
The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.
This function can be safely used for constructing (and later destructing) objects even without any OpenGL context being active. However note that this is a low-level and a potentially dangerous API, see the documentation of NoCreate for alternatives.
Magnum:: GL:: Buffer:: Buffer(TargetHint targetHint,
Containers:: ArrayView<const void> data,
BufferUsage usage = BufferUsage:: StaticDraw) explicit new in 2020.06
Construct and directly fill with data.
Parameters | |
---|---|
targetHint | Target hint, see setTargetHint() for more information |
data | Data |
usage | Buffer usage |
Equivalent to constructing via Buffer(TargetHint) and then calling setData().
template<class T>
Magnum:: GL:: Buffer:: Buffer(TargetHint targetHint,
std:: initializer_list<T> data,
BufferUsage usage = BufferUsage:: StaticDraw) explicit new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Magnum:: GL:: Buffer:: Buffer(Containers:: ArrayView<const void> data,
BufferUsage usage = BufferUsage:: StaticDraw) explicit new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Equivalent to calling Buffer(TargetHint, Containers::{}
-style construction. Use the above overload or the Corrade::
GLuint Magnum:: GL:: Buffer:: release()
Release OpenGL object.
Releases ownership of OpenGL buffer object and returns its ID so it is not deleted on destruction. The internal state is then equivalent to moved-from state.
Containers:: String Magnum:: GL:: Buffer:: label()
Buffer label.
The result is not cached, repeated queries will result in repeated OpenGL calls. If OpenGL 4.3 / OpenGL ES 3.2 is not supported and neither KHR_
Buffer& Magnum:: GL:: Buffer:: setLabel(Containers:: StringView label)
Set buffer label.
Returns | Reference to self (for method chaining) |
---|
Default is empty string. If OpenGL 4.3 / OpenGL ES 3.2 is not supported and neither KHR_
Buffer& Magnum:: GL:: Buffer:: setTargetHint(TargetHint hint)
Set target hint.
Returns | Reference to self (for method chaining) |
---|
If ARB_
Buffer& Magnum:: GL:: Buffer:: bind(Target target,
UnsignedInt index,
GLintptr offset,
GLsizeiptr size)
Bind buffer range to given binding index.
The index
parameter must respect limits for given target
. The offset
parameter must respect alignment, which is 4 bytes for Target::
Buffer& Magnum:: GL:: Buffer:: bind(Target target,
UnsignedInt index)
Bind buffer to given binding index.
The index
parameter must respect limits for given target
. The buffer must have allocated data store.
Buffer& Magnum:: GL:: Buffer:: setStorage(Containers:: ArrayView<const void> data,
StorageFlags flags) new in Git master
Set storage.
Parameters | |
---|---|
data | Data |
flags | Storage flags |
If ARB_
Buffer& Magnum:: GL:: Buffer:: setStorage(std:: size_t size,
StorageFlags flags) new in Git master
Set storage.
Parameters | |
---|---|
size | Size in bytes |
flags | Storage flags |
Equivalent to calling setStorage(Containers::nullptr
view of size
bytes.
Int Magnum:: GL:: Buffer:: size()
Buffer size in bytes.
If ARB_
Containers:: Array<char> Magnum:: GL:: Buffer:: data()
Buffer data.
Returns data of whole buffer. If ARB_
Containers:: Array<char> Magnum:: GL:: Buffer:: subData(GLintptr offset,
GLsizeiptr size)
Buffer subdata.
Parameters | |
---|---|
offset | Byte offset in the buffer |
size | Data size in bytes |
Returns data of given buffer portion. If ARB_
Buffer& Magnum:: GL:: Buffer:: setData(Containers:: ArrayView<const void> data,
BufferUsage usage = BufferUsage:: StaticDraw)
Set buffer data.
Parameters | |
---|---|
data | Data |
usage | Buffer usage |
Returns | Reference to self (for method chaining) |
If ARB_
template<class T>
Buffer& Magnum:: GL:: Buffer:: setData(std:: initializer_list<T> data,
BufferUsage usage = BufferUsage:: StaticDraw) new in 2019.10
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Buffer& Magnum:: GL:: Buffer:: setSubData(GLintptr offset,
Containers:: ArrayView<const void> data)
Set buffer subdata.
Parameters | |
---|---|
offset | Byte offset in the buffer |
data | Data |
Returns | Reference to self (for method chaining) |
If ARB_
template<class T>
Buffer& Magnum:: GL:: Buffer:: setSubData(GLintptr offset,
std:: initializer_list<T> data) new in 2019.10
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Buffer& Magnum:: GL:: Buffer:: invalidateData()
Invalidate buffer data.
Returns | Reference to self (for method chaining) |
---|
If running on OpenGL ES or extension ARB_
Buffer& Magnum:: GL:: Buffer:: invalidateSubData(GLintptr offset,
GLsizeiptr length)
Invalidate buffer subdata.
Parameters | |
---|---|
offset | Byte offset into the buffer |
length | Length of the invalidated range |
Returns | Reference to self (for method chaining) |
If running on OpenGL ES or extension ARB_
char* Magnum:: GL:: Buffer:: map(MapAccess access)
Map buffer to client memory.
Parameters | |
---|---|
access | Access |
Returns | Pointer to mapped buffer data or nullptr on error |
If ARB_
const char* Magnum:: GL:: Buffer:: mapRead()
Map buffer read-only to client memory.
Equivalent to map() with MapAccess::
Containers:: ArrayView<char> Magnum:: GL:: Buffer:: map(GLintptr offset,
GLsizeiptr length,
MapFlags flags)
Map buffer to client memory.
Parameters | |
---|---|
offset | Byte offset into the buffer |
length | Length of the mapped memory in bytes |
flags | Flags. At least MapFlag:: |
Returns | Sized view to buffer data or nullptr on error |
If ARB_
Containers:: ArrayView<const char> Magnum:: GL:: Buffer:: mapRead(GLintptr offset,
GLsizeiptr length,
MapFlags flags = {})
Map buffer read-only to client memory.
Equivalent to map() with MapFlag::
Buffer& Magnum:: GL:: Buffer:: flushMappedRange(GLintptr offset,
GLsizeiptr length)
Flush mapped range.
Parameters | |
---|---|
offset | Byte offset relative to start of mapped range |
length | Length of the flushed memory in bytes |
Returns | Reference to self (for method chaining) |
Flushes specified subsection of mapped range. Use only if you called map() with MapFlag::
If ARB_
bool Magnum:: GL:: Buffer:: unmap()
Unmap buffer.
Returns | False if the data have become corrupt during the time the buffer was mapped (e.g. after screen was resized), true otherwise. |
---|
Unmaps buffer previously mapped with map() / mapRead(), invalidating the pointer returned by these functions. If ARB_
Debug& operator<<(Debug& debug,
Buffer:: TargetHint value)
Debug output operator.
Debug& operator<<(Debug& debug,
Buffer:: Target value)
Debug output operator.