unsigned int numIndices = 0;
if( indexBuffer )
{
- numIndices = /* TODO: MESH_REWORK remove this 2, should implement unsigned short properties */ 2 * indexBuffer->GetDataSize(bufferIndex) / indexBuffer->GetElementSize(bufferIndex);
+ numIndices = indexBuffer->GetDataSize(bufferIndex) / indexBuffer->GetElementSize(bufferIndex);
}
switch(type)
if ( ! hasGpuBuffer || mDataProvider.HasDataChanged( bufferIndex ) )
{
std::size_t dataSize = mDataProvider.GetDataSize( bufferIndex );
- mGpuBuffer->UpdateDataBuffer( dataSize, &(mDataProvider.GetData( bufferIndex )[0]) );
+
+ const void *data = &(mDataProvider.GetData( bufferIndex )[0]);
+
+ // Index buffer needs to be unsigned short which is not supported by the property system
+ if( mGpuBufferTarget == GpuBuffer::ELEMENT_ARRAY_BUFFER )
+ {
+ Vector<unsigned short> ushortData;
+ ushortData.Resize( dataSize );
+ const unsigned int* unsignedData = static_cast<const unsigned int*>(data);
+ for( unsigned int i = 0; i < dataSize; ++i )
+ {
+ ushortData[i] = unsignedData[i];
+ }
+ data = &(ushortData[0]);
+ }
+
+ mGpuBuffer->UpdateDataBuffer( dataSize, data );
mGpuBuffer->SetStride( mDataProvider.GetElementSize( bufferIndex ) );
}
}