![]() |
CUGL 4.0
Cornell University Game Library
|
#include <CUIndexBuffer.h>
Public Member Functions | |
| IndexBuffer () | |
| ~IndexBuffer () | |
| void | dispose () |
| bool | init (size_t size, BufferAccess access=BufferAccess::DYNAMIC) |
| bool | initShort (size_t size, BufferAccess access=BufferAccess::DYNAMIC) |
| void | setName (std::string name) |
| const std::string | getName () const |
| BufferData * | getImplementation () |
| size_t | getCapacity () const |
| BufferAccess | getAccess () const |
| size_t | getSize () const |
| bool | isShort () const |
| bool | loadData (const Uint32 *data, size_t size) |
| bool | loadData (const std::vector< Uint32 > &data) |
| bool | loadData (const Uint16 *data, size_t size) |
| bool | loadData (const std::vector< Uint16 > &data) |
Static Public Member Functions | |
| static std::shared_ptr< IndexBuffer > | alloc (size_t size, BufferAccess access=BufferAccess::DYNAMIC) |
| static std::shared_ptr< IndexBuffer > | allocShort (size_t size, BufferAccess access=BufferAccess::DYNAMIC) |
Protected Member Functions | |
| void | setup (size_t size) |
Protected Attributes | |
| std::string | _name |
| BufferData * | _data |
| size_t | _capacity |
| BufferAccess | _access |
| bool | _short |
| size_t | _size |
This class defines an index buffer for drawing with a shader.
A index buffer is a collection of integers refering to elements of a shader's vertex buffer(s). Typically a GraphicsShader takes both a vertex buffer and an index buffer, and previous versions of CUGL bundled them together. These are separate objects to allow shaders to work with multiple vertex buffers, one for each binding.
Index buffers can either be 16-bit (shorts) or 32-bit. This choice is made at creation time and cannot be changed. The variations of loadData will convert the data accordingly.
| cugl::graphics::IndexBuffer::IndexBuffer | ( | ) |
Creates an uninitialized index buffer.
You must initialize the index buffer to allocate buffer memory.
|
inline |
Deletes this index buffer, disposing all resources.
|
inlinestatic |
Returns a new index buffer to support 32-bit integers
The size given is the maximum number of integers to store in this buffer, not the number of bytes.
Note that some access types such as BufferAccess#STATIC or BufferAccess#COMPUTE_ONLY can only be updated once. Any attempts to load data after the first time will fail.
| size | The maximum number of integers in this buffer |
| access | The buffer access |
|
inlinestatic |
Returns a new index buffer to support 16-bit integers
The size given is the maximum number of short integers to store in this buffer, not the number of bytes.
Note that some access types such as BufferAccess#STATIC or BufferAccess#COMPUTE_ONLY can only be updated once. Any attempts to load data after the first time will fail.
| size | The maximum number of short integers in this buffer |
| access | The buffer access |
| void cugl::graphics::IndexBuffer::dispose | ( | ) |
Deletes the index buffer, freeing all resources.
You must reinitialize the index buffer to use it.
|
inline |
Returns the access policy of this index buffer
|
inline |
Returns the maximum capacity of this buffer.
The size determines the number of elements that can be loaded with the method loadData.
|
inline |
Returns the platform-specific implementation for this buffer
The value returned is an opaque type encapsulating the information for either OpenGL or Vulkan.
|
inline |
Returns the name of this index buffer.
A name is a user-defined way of identifying a buffer. It is used for debugging purposes only, and has no affect on the graphics pipeline.
|
inline |
Returns the number of indices currently stored in this buffer
| bool cugl::graphics::IndexBuffer::init | ( | size_t | size, |
| BufferAccess | access = BufferAccess::DYNAMIC |
||
| ) |
Initializes this index buffer to support 32-bit integers
The size given is the maximum number of integers to store in this buffer, not the number of bytes.
Note that some access types such as BufferAccess#STATIC or BufferAccess#COMPUTE_ONLY can only be updated once. Any attempts to load data after the first time will fail.
| size | The maximum number of integers in this buffer |
| access | The buffer access |
| bool cugl::graphics::IndexBuffer::initShort | ( | size_t | size, |
| BufferAccess | access = BufferAccess::DYNAMIC |
||
| ) |
Initializes this index buffer to support 16-bit integers
The size given is the maximum number of short integers to store in this buffer, not the number of bytes.
Note that some access types such as BufferAccess#STATIC or BufferAccess#COMPUTE_ONLY can only be updated once. Any attempts to load data after the first time will fail.
| size | The maximum number of short integers in this buffer |
| access | The buffer access |
|
inline |
Returns true if this buffer uses short (16-bit) indices
If the value is false, this buffer used 32-bit indices.
|
inline |
Loads the given index buffer with the given data.
If this is not a dynamic buffer, then this method can only be called once. Additional attempts to load into a static buffer will fail.
If this buffer only supports 32-bit indices, they will be converted before loading into this buffer.
| data | The data to load |
|
inline |
Loads the given index buffer with the given data.
If this is not a dynamic buffer, then this method can only be called once. Additional attempts to load into a static buffer will fail.
If this buffer only supports 16-bit indices, they will be converted before loading into this buffer. Note that this conversion may lose data.
| data | The data to load |
| bool cugl::graphics::IndexBuffer::loadData | ( | const Uint16 * | data, |
| size_t | size | ||
| ) |
Loads the given index buffer with the given data.
If this is not a dynamic buffer, then this method can only be called once. Additional attempts to load into a static buffer will fail.
If this buffer only supports 32-bit indices, they will be converted before loading into this buffer.
| data | The data to load |
| size | The number of elements to load |
| bool cugl::graphics::IndexBuffer::loadData | ( | const Uint32 * | data, |
| size_t | size | ||
| ) |
Loads the given index buffer with the given data.
If this is not a dynamic buffer, then this method can only be called once. Additional attempts to load into a static buffer will fail.
If this buffer only supports 16-bit indices, they will be converted before loading into this buffer. Note that this conversion may lose data.
| data | The data to load |
| size | The number of elements to load |
|
inline |
Sets the name of this index buffer.
A name is a user-defined way of identifying a buffer. It is used for debugging purposes only, and has no affect on the graphics pipeline.
| name | The name of this index buffer. |
|
protected |
Allocates the initial buffers for a index buffer
| size | The index byte size |
|
protected |
The buffer access
|
protected |
The maximum number of indices supported
|
protected |
The graphics API implementation of this buffer
|
protected |
The name of this index buffer
|
protected |
Whether to use short indices
|
protected |
The number of indices loaded into the buffer