13 #ifndef OGLPLUS_BUFFER_1107121519_HPP
14 #define OGLPLUS_BUFFER_1107121519_HPP
48 static void Gen(tag::Generate, GLsizei count, GLuint* names)
50 assert(names !=
nullptr);
51 OGLPLUS_GLFUNC(GenBuffers)(count, names);
52 OGLPLUS_CHECK_SIMPLE(GenBuffers);
54 #if GL_VERSION_4_5 || GL_ARB_direct_state_access
55 static void Gen(tag::Create, GLsizei count, GLuint* names)
57 assert(names !=
nullptr);
58 OGLPLUS_GLFUNC(GenBuffers)(count, names);
59 OGLPLUS_CHECK_SIMPLE(GenBuffers);
63 static void Delete(GLsizei count, GLuint* names)
65 assert(names !=
nullptr);
66 OGLPLUS_GLFUNC(DeleteBuffers)(count, names);
67 OGLPLUS_VERIFY_SIMPLE(DeleteBuffers);
70 static GLboolean IsA(GLuint name)
73 GLboolean result = OGLPLUS_GLFUNC(IsBuffer)(name);
74 OGLPLUS_VERIFY_SIMPLE(IsBuffer);
116 OGLPLUS_GLFUNC(BindBuffer)(
148 OGLPLUS_GLFUNC(BindBufferBase)(
173 OGLPLUS_GLFUNC(BindBufferRange)(
177 GLintptr(offset.
Get()),
178 GLsizeiptr(size.
Get())
188 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_4 || GL_ARB_multi_bind
189 static void BindBase(
196 OGLPLUS_GLFUNC(BindBuffersBase)(
224 GLsizei(buffers.
size()),
229 static void BindRange(
234 const GLintptr* offsets,
235 const GLsizeiptr* sizes
238 OGLPLUS_GLFUNC(BindBuffersRange)(
253 static void BindRange(
256 const Sequence<BufferName>& buffers,
257 const GLintptr* offsets,
258 const GLsizeiptr* sizes
264 GLsizei(buffers.size()),
280 ,
public ObjBindingOps<tag::Buffer>
299 void Bind(IndexedTarget target, GLuint index)
const
301 BindBase(target, index, *
this);
311 BindBase(target, index, *
this);
314 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_0 || GL_ARB_transform_feedback3
327 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_0 || GL_ARB_transform_feedback3
342 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_2 || GL_ARB_shader_atomic_counters
355 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_3 || GL_ARB_shader_storage_buffer_object
380 BindRange(target, index, *
this, offset, size);
383 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_3 || GL_ARB_invalidate_subdata
395 OGLPLUS_GLFUNC(InvalidateBufferData)(_name);
397 InvalidateBufferData,
415 OGLPLUS_GLFUNC(InvalidateBufferSubData)(
417 GLintptr(offset.
Get()),
418 GLsizeiptr(size.
Get())
421 InvalidateBufferSubData,
434 :
public ObjZeroOps<tag::ExplicitSel, tag::Buffer>
439 static GLint GetIntParam(
Target target, GLenum query);
451 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_0
465 return GetIntParam(target, GL_BUFFER_MAPPED) == GL_TRUE;
467 #endif // GL_VERSION_3_0
494 ObjectBinding(target).
515 GLsizei(data.Size()),
522 ObjectBinding(target).
555 template <
typename GLtype>
572 OGLPLUS_GLFUNC(BufferSubData)(
574 GLintptr(offset.
Get()),
575 GLsizei(data.Size()),
581 ObjectBinding(target)
591 template <
typename GLtype>
599 SubData(target, offset,
BufferData(count, data));
602 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_1 || GL_ARB_copy_buffer
619 OGLPLUS_GLFUNC(CopyBufferSubData)(
622 GLintptr(readoffset.
Get()),
623 GLintptr(writeoffset.
Get()),
624 GLsizeiptr(size.
Get())
629 SubjectBinding(readtarget).
630 ObjectBinding(writetarget)
633 #endif // copy buffer
635 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_3
647 template <
typename GLtype>
655 OGLPLUS_GLFUNC(ClearBufferData)(
657 GLenum(internal_format),
659 GLenum(GetDataType<GLtype>()),
665 ObjectBinding(target)
680 template <
typename GLtype>
690 OGLPLUS_GLFUNC(ClearBufferSubData)(
692 GLenum(internal_format),
693 GLintptr(offset.
Get()),
694 GLsizeiptr(size.
Get()),
696 GLenum(GetDataType<GLtype>()),
702 ObjectBinding(target).
703 EnumParam(internal_format)
708 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_4 || GL_ARB_buffer_storage
715 OGLPLUS_GLFUNC(BufferStorage)(
717 GLsizeiptr(data.Size()),
724 ObjectBinding(target)
747 Storage(target,
BufferData(size, data), flags);
763 GL_BUFFER_IMMUTABLE_STORAGE
779 GetIntParam(target, GL_BUFFER_STORAGE_FLAGS)
784 #if OGLPLUS_DOCUMENTATION_ONLY || GL_ARB_sparse_buffer
785 static void PageCommitment(
792 OGLPLUS_GLFUNC(BufferPageCommitmentARB)(
794 GLintptr(offset.
Get()),
795 GLsizeiptr(size.
Get()),
796 commit?GL_TRUE:GL_FALSE
799 BufferPageCommitmentARB,
801 ObjectBinding(target)
805 static GLsizei PageSize(
void)
808 OGLPLUS_GLFUNC(GetIntegerv)(
809 GL_SPARSE_BUFFER_PAGE_SIZE_ARB,
812 OGLPLUS_VERIFY_SIMPLE(GetIntegerv);
813 return GLsizei(value);
827 return GLsizei(GetIntParam(target, GL_BUFFER_SIZE));
842 return BufferUsage(GetIntParam(target, GL_BUFFER_USAGE));
845 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_0
859 GLbitfield(GetIntParam(target, GL_BUFFER_ACCESS))
864 #if OGLPLUS_DOCUMENTATION_ONLY || GL_NV_shader_buffer_load
875 OGLPLUS_GLFUNC(MakeBufferResidentNV)(
880 MakeBufferResidentNV,
882 ObjectBinding(target)
896 OGLPLUS_GLFUNC(MakeBufferNonResidentNV)(GLenum(target));
898 MakeBufferNonResidentNV,
900 ObjectBinding(target)
915 GLuint64EXT value = 0;
916 OGLPLUS_GLFUNC(GetBufferParameterui64vNV)(
918 GL_BUFFER_GPU_ADDRESS_NV,
922 GetBufferParameterui64vNV,
924 ObjectBinding(target)
926 return BufferGPUAddress(value);
932 typedef ObjectOps<tag::ExplicitSel, tag::Buffer>
936 struct BufferTargetAndUsage
947 inline BufferTargetAndUsage operator << (
952 return BufferTargetAndUsage(target, usage);
956 struct BufferOpsAndIdxTgt
967 inline BufferOpsAndIdxTgt operator << (
972 return BufferOpsAndIdxTgt(buf, target);
976 struct BufferTargetAndOffset
987 inline BufferTargetAndOffset operator + (
992 return BufferTargetAndOffset(target, offset);
1007 const BufferOpsAndIdxTgt& bat,
1011 bat.buf.BindBase(bat.target, index);
1018 const BufferData& data
1027 BufferTargetAndUsage&& tau,
1028 const BufferData& data
1037 BufferTargetAndOffset&& tao,
1038 const BufferData& data
1041 BufferOps::SubData(tao.target, tao.offset, data);
1049 typedef ObjectZero<ObjZeroOps<tag::ExplicitSel, tag::Buffer>>
1060 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
1061 #include <oglplus/buffer.ipp>
1062 #endif // OGLPLUS_LINK_LIBRARY
1064 #endif // include guard
BufferMapAccess MapAccess
The buffer map access mode.
Definition: buffer.hpp:448
static void MakeResident(Target target, AccessSpecifier access)
Makes buffer currently bound to target accessible to GLSL shaders.
Definition: buffer.hpp:873
Common base class for Object name sequences.
Definition: fwd.hpp:139
BufferIndexedTarget IndexedTarget
Buffer indexed bind targets.
Definition: buffer.hpp:94
static BufferName Binding(Target target)
Returns the current Buffer bound to specified target.
Definition: buffer.hpp:101
PixelDataInternalFormat
OpenGL pixel data internal format enumeration.
Definition: pixel_data.hpp:79
Access type specifier enumeration.
Buffer bind target enumerations.
static BufferName Binding(IndexedTarget target, GLuint idx)
Returns the current Buffer bound to specified indexed target.
Definition: buffer.hpp:133
static void CopySubData(BufferTarget readtarget, BufferTarget writetarget, BufferSize readoffset, BufferSize writeoffset, BufferSize size)
Copy data between buffers.
Definition: buffer.hpp:611
static bool Mapped(Target target)
Returns true if the buffer is mapped.
Definition: buffer.hpp:463
This class represents the size of a GPU buffer in bytes.
Definition: buffer_size.hpp:22
BufferUsage
Buffer usage enumeration.
Definition: buffer_usage.hpp:24
Typed mapping of the buffer to the client address space.
Definition: buffer_map.hpp:231
Declaration of OGLplus object-related error.
Generic OpenGL object wrapper.
static void SubData(Target target, BufferSize offset, GLsizei count, const GLtype *data)
Uploads (sets) a subrange of the buffer data.
Definition: buffer.hpp:592
Object wrapping data to be stored in a Buffer.
std::size_t size(void) const
Returns the size of the sequence.
Definition: seq_tpl.hpp:166
This template serves as a wrapper for OpenGL bitfields.
Definition: bitfield.hpp:56
TRANSFORM_FEEDBACK_BUFFER.
Buffer usage enumeration.
static BufferUsage Usage(Target target)
Returns the buffer usage.
Definition: buffer.hpp:840
Implements operations applicable to named (non-zero) objects.
Definition: wrap_tpl.hpp:45
void BindBaseAtomicCounter(AtomicCounterBufferBindingPoint index) const
Bind this buffer to the specified atomic counter buffer binding point.
Definition: buffer.hpp:349
static Bitfield< BufferMapAccess > Access(Target target)
Returns the buffer usage.
Definition: buffer.hpp:856
GLuint GetGLName(ObjectName< ObjTag > named)
Returns the GLuint OpenGL name assigned to named object.
Definition: name.hpp:38
AccessSpecifier
Enumeration of access type specifiers.
Definition: access_specifier.hpp:27
void InvalidateData(void)
Invalidate the buffer data.
Definition: buffer.hpp:393
ObjectOps< tag::ExplicitSel, tag::Buffer > BufferOps
The buffer operations with explicit selector.
Definition: buffer.hpp:933
static void ClearData(Target target, PixelDataInternalFormat internal_format, PixelDataFormat format, const GLtype *data)
Clear the buffer data.
Definition: buffer.hpp:648
void BindBaseUniform(UniformBufferBindingPoint index) const
Bind this buffer to the specified uniform buffer binding point.
Definition: buffer.hpp:321
Sequence of Object names.
PixelDataFormat
OpenGL pixel data format enumeration.
Definition: pixel_data.hpp:50
static void Bind(Target target, BufferName buffer)
Binds the specified buffer to the specified target.
Definition: buffer.hpp:111
static void Data(Target target, GLsizei count, const GLtype *data, BufferUsage usage=BufferUsage::StaticDraw)
Uploads (sets) the buffer data.
Definition: buffer.hpp:556
static void Resize(Target target, BufferSize size, BufferUsage usage=BufferUsage::StaticDraw)
Allocates buffer storage to the specified size without any data.
Definition: buffer.hpp:479
Helper macro for optional checking of availability of GL function.
void BindBase(IndexedTarget target, GLuint index) const
Binds this buffer to the specified indexed target.
Definition: buffer.hpp:309
const GLuint * GetGLNames(const Sequence< ObjName > &sequence)
Returns a pointer to array of GL object names stored in a sequence.
Definition: sequence.hpp:23
Implements operations applicable to any object including object 0 (zero)
Definition: fwd.hpp:157
void InvalidateSubData(BufferSize offset, BufferSize size)
Invalidate a subrange of the buffer data.
Definition: buffer.hpp:413
void BindBaseShaderStorage(ShaderStorageBufferBindingPoint index) const
Bind this buffer to the specified shader storage buffer binding point.
Definition: buffer.hpp:362
ObjectZero< ObjZeroOps< tag::ExplicitSel, tag::Buffer > > NoBuffer
Class that can be used to unbind the currently bound buffers.
Definition: buffer.hpp:1050
Data type-related declarations.
GLsizeiptr Get(void) const
Gets the size in bytes.
Definition: buffer_size.hpp:58
BufferMapAccess
Buffer map access enumeration.
Definition: buffer_map_access.hpp:25
Pixel data-related declarations.
static void Storage(Target target, BufferSize size, const void *data, Bitfield< BufferStorageBit > flags)
Creates a data store for a buffer object.
Definition: buffer.hpp:740
Class used for passing the size of and pointer to data to be put in a Buffer.
Definition: buffer_data.hpp:21
BufferIndexedTarget
Buffer indexed bind target.
Definition: buffer_target.hpp:46
BufferTarget Target
Buffer bind targets.
Definition: buffer.hpp:91
Object representing Buffer's GPU address.
static void BindBase(BufferIndexedTarget target, GLuint first, const Sequence< BufferName > &buffers)
Sequentially binds buffers to target starting at first index.
Definition: buffer.hpp:215
Type for the atomic counter buffer binding point index.
Definition: buffer_binding.hpp:58
Buffer storage bit enumeration.
void BindBaseTransformFeedback(TransformFeedbackBufferBindingPoint index) const
Bind this buffer to the specified TFB buffer binding point.
Definition: buffer.hpp:334
Exception class for GL object-related errors.
Definition: object.hpp:24
static void Data(Target target, const BufferData &data, BufferUsage usage=BufferUsage::StaticDraw)
Uploads (sets) the buffer data.
Definition: buffer.hpp:507
static void MakeNonResident(Target target)
Makes buffer currently bound to target inaccessible to GLSL shaders.
Definition: buffer.hpp:894
Type for the shader storage buffer binding point index.
Definition: buffer_binding.hpp:76
Object< BufferOps > Buffer
An oglplus_object encapsulating the OpenGL buffer functionality.
Definition: buffer.hpp:1056
static void BindBase(IndexedTarget target, GLuint index, BufferName buffer)
Bind the specified buffer to the specified indexed target.
Definition: buffer.hpp:142
static void RawData(Target target, BufferSize size, const GLvoid *data, BufferUsage usage=BufferUsage::StaticDraw)
Uploads (sets) the buffer data.
Definition: buffer.hpp:536
static Bitfield< BufferStorageBit > StorageFlags(Target target)
Returns the buffer storage flags.
Definition: buffer.hpp:776
static bool ImmutableStorage(Target target)
Returns true if the buffer storage is immutable.
Definition: buffer.hpp:759
void BindRange(IndexedTarget target, GLuint index, BufferSize offset, BufferSize size) const
Binds a range in this buffer to the specified indexed target.
Definition: buffer.hpp:373
Implements operations applicable to any object and any operation kind.
Definition: fwd.hpp:151
BufferUsage Usage
The Buffer usage mode.
Definition: buffer.hpp:445
static GLsizei Size(Target target)
Returns the buffer size.
Definition: buffer.hpp:825
static BufferGPUAddress GPUAddress(Target target)
Returns the GPU address of the buffer currently bound to target.
Definition: buffer.hpp:913
Buffer binding point indices.
static void BindRange(IndexedTarget target, GLuint index, BufferName buffer, BufferSize offset, BufferSize size)
Bind a range the specified buffer to the specified indexed target.
Definition: buffer.hpp:165
void Bind(Target target) const
Binds this buffer to the specified target.
Definition: buffer.hpp:294
A common template for "named" objects like textures, buffers, etc.
Definition: fwd.hpp:136
static void ClearSubData(Target target, PixelDataInternalFormat internal_format, BufferSize offset, BufferSize size, PixelDataFormat format, const GLtype *data)
Clear a subrange of the buffer data.
Definition: buffer.hpp:681
BufferTarget
Buffer bind target.
Definition: buffer_target.hpp:24