IDevice::createIndexBuffer - dpw105f18/papago-api GitHub Wiki

Create an index buffer

unique_ptr<IBufferResource> createIndexBuffer(vector<T> index_data)

Returns

Returns a unique pointer to an IBufferResource containing a index buffer

Parameters

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.

Exceptions

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
   });
}
⚠️ **GitHub.com Fallback** ⚠️