unique_ptr<IBufferResource> createIndexBuffer(vector<T> index_data)
Returns a unique pointer to an IBufferResource containing a index buffer
| Parameter |
Description |
| index_data |
A vector which can consist of T elements, where T can be uint_16 or uint_32. Its contents are uploaded to the GPU as an index buffer. |
| Exception |
Error Code |
Description |
| std::system_error |
-1 |
out of host memory |
| std::system_error |
-2 |
out of device memory |
Example of createIndexBuffer
#include <vector>
#include "idevice.hpp"
struct vec2
{
float x, y;
};
int main()
{
/*
setup code omitted
*/
//Create a Index Buffer
auto indexBufferExample = device->createIndexBuffer(std::vector<uint32_t>
{
//Index buffer which arranges vertices to form a square
0, 1, 2
2, 3, 0
});
}