fix not creating an index buffer on the GPU if a graphics device object is passed in, and ensure all Initialize() overloads call BufferObject's Initialize() as well

This commit is contained in:
Gered 2013-04-03 12:30:01 -04:00
parent 52d9989224
commit c5d4a3094c

View file

@ -38,6 +38,9 @@ bool IndexBuffer::Initialize(GraphicsDevice *graphicsDevice, uint numIndices, BU
Resize(numIndices); Resize(numIndices);
if (graphicsDevice != NULL)
CreateOnGpu();
return true; return true;
} }
@ -60,9 +63,15 @@ bool IndexBuffer::Initialize(GraphicsDevice *graphicsDevice, const IndexBuffer *
if (source->GetNumElements() == 0) if (source->GetNumElements() == 0)
return false; return false;
if (!BufferObject::Initialize(graphicsDevice, BUFFEROBJECT_TYPE_INDEX, source->GetUsage()))
return false;
Resize(source->GetNumElements()); Resize(source->GetNumElements());
memcpy(&m_buffer[0], source->GetBuffer(), GetNumElements() * GetElementWidthInBytes()); memcpy(&m_buffer[0], source->GetBuffer(), GetNumElements() * GetElementWidthInBytes());
if (graphicsDevice != NULL)
CreateOnGpu();
return true; return true;
} }