![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/GL/IndexBuffer.h>
Specialization of Buffer to store vertex index data (GL_ELEMENT_ARRAY_BUFFER).
More...
Inheritance diagram for IndexBuffer:Specialization of Buffer to store vertex index data (GL_ELEMENT_ARRAY_BUFFER).
Can be passed to a GL::VertexBuffer::draw() call for indexed rendering where the same vertex data can be used by multiple vertices to reduce memory usage.
Example for rendering a quad using indexed rendering:
Public Member Functions | |
| IndexBuffer (Usage usageHint=Buffer::Usage::StaticDraw) | |
| Default constructs an empty index buffer. | |
| uint32_t | primitiveRestartIndex () const |
| Returns the OpenGL primitive restart index to use during indexed rendering. | |
| void | setPrimitiveRestartIndex (uint32_t value) |
| Sets the OpenGL primitive restart index to use during indexed rendering. | |
| size_t | numElements () const |
| Return the number of indices stored in the buffer. | |
| PixelType | type () const |
| Return the index data type. | |
| void | setData (Utils::Span< uint8_t > indices) |
Upload uint8_t vertex indices to the buffer. | |
| void | setData (Utils::Span< uint16_t > indices) |
Upload uint16_t vertex indices to the buffer. | |
| void | setData (Utils::Span< uint32_t > indices) |
Upload uint32_t vertex indices to the buffer. | |
| void | setData (Utils::Span< vec3i > indices) |
Upload non-negative int32_t triplets describing a series of triangles to the vertex index buffer. | |
Public Member Functions inherited from Buffer | |
| Buffer (Target target, Usage usage) | |
| Creates a new Buffer. | |
| void | bind () const |
| Binds the buffer to the target given during construction. | |
| Usage | usageHint () const |
| Returns the buffer usage hint passed to OpenGL during allocation. | |
| void | setUsageHint (Usage value) |
| Sets the buffer usage hint passed to OpenGL during allocation. | |
| uint32_t | id () const |
| Return a handle to the internal OpenGL buffer object. | |
Static Public Member Functions | |
| static void | unbind () |
| Unbind any bound index buffer. | |
Static Public Member Functions inherited from Buffer | |
| static void | unbind (Target target) |
| Binds 0 to the specified target. | |
Additional Inherited Members | |
Public Types inherited from Buffer | |
| enum class | Target { Array = 0x8892 , AtomicCounter = 0x92C0 , CopyRead = 0x8F36 , CopyWrite = 0x8F37 , DrawIndirect = 0x8F3F , ElementArray = 0x8893 , PixelPack = 0x88EB , PixelUnpack = 0x88EC , ShaderStorage = 0x90D2 , Texture = 0x8C2A , TransformFeedback = 0x8C8E , Uniform = 0x8A11 } |
| Enumeration of the different OpenGL buffer types. More... | |
| enum class | Usage { StreamDraw = 0x88E0 , StreamRead = 0x88E1 , StreamCopy = 0x88E2 , StaticDraw = 0x88E4 , StaticRead = 0x88E5 , StaticCopy = 0x88E6 , DynamicDraw = 0x88E8 , DynamicRead = 0x88E9 , DynamicCopy = 0x88EA } |
| Enumeration for usage pattern hints to provide to the GPU when allocating data. More... | |
Protected Member Functions inherited from Buffer | |
| void | allocateBuffer (int64_t numBytes) |
| Allocates storage on the GPU for this buffer object. | |
| template<typename... Ts> | |
| void | setSubData (size_t offset, Utils::Span< Ts >... data) |
| Upload data into the buffer starting at the given offset. | |
| template<typename... Ts> | |
| size_t | getBufferSize (Utils::Span< Ts >... data) const |
| Compute the total number of bytes used by all provided data together. | |
Static Protected Member Functions inherited from Buffer | |
| static void | glBufferSubDataImpl (Target target, int64_t offset, int64_t size, const void *data) |
forwards to OpenGL's glBufferSubData(). | |
| static void | glGetBufferSubDataImpl (Target target, int64_t offset, int64_t size, void *data) |
forwards to OpenGL's glGetBufferSubData(). | |
Protected Attributes inherited from Buffer | |
| const Target | m_target |
| Target binding point for the buffer, will never change for a Buffer instance. | |
| Usage | m_usageHint |
| Buffer usage hint passed to OpenGL unless explicitly specified otherwise. | |
| uint32_t | m_id = 0 |
| Internal OpenGL handle to buffer object. | |
| int64_t | m_bufferSize = 0 |
| Number of bytes allocated on the GPU. | |
| IndexBuffer | ( | Usage | usageHint = Buffer::Usage::StaticDraw | ) |
Default constructs an empty index buffer.
| usageHint | Expected usage pattern of the buffer |
| std::runtime_error | if the corresponding OpenGL buffer object could not be created. |
| uint32_t primitiveRestartIndex | ( | ) | const |
Returns the OpenGL primitive restart index to use during indexed rendering.
The primitive restart feature is disabled if the index is 0 (default behavior).
| void setPrimitiveRestartIndex | ( | uint32_t | value | ) |
Sets the OpenGL primitive restart index to use during indexed rendering.
The primitive restart feature is disabled if the index is 0 (default behavior). On WebGL, the features is always enabled. Check the class documentation for details.
| void setData | ( | Utils::Span< uint8_t > | indices | ) |
Upload uint8_t vertex indices to the buffer.
The buffer needs to be bound before this method is called. Any previous data will be deleted.
| indices | Contiguous sequence of index data that should be copied to the buffer. |
| void setData | ( | Utils::Span< uint16_t > | indices | ) |
Upload uint16_t vertex indices to the buffer.
The buffer needs to be bound before this method is called. Any previous data will be deleted.
| indices | Contiguous sequence of index data that should be copied to the buffer. |
| void setData | ( | Utils::Span< uint32_t > | indices | ) |
Upload uint32_t vertex indices to the buffer.
The buffer needs to be bound before this method is called. Any previous data will be deleted.
| indices | Contiguous sequence of index data that should be copied to the buffer. |
| void setData | ( | Utils::Span< vec3i > | indices | ) |
Upload non-negative int32_t triplets describing a series of triangles to the vertex index buffer.
The buffer needs to be bound before this method is called. Any previous data will be deleted.
| indices | Contiguous sequence of index data that should be copied to the buffer. Must not contain any negative elements. |