From c5d4a3094cb9de32aefc16a2faaa513aa0448eff Mon Sep 17 00:00:00 2001 From: gered Date: Wed, 3 Apr 2013 12:30:01 -0400 Subject: [PATCH] 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 --- src/framework/graphics/indexbuffer.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/framework/graphics/indexbuffer.cpp b/src/framework/graphics/indexbuffer.cpp index b7d75a4..49a4e51 100644 --- a/src/framework/graphics/indexbuffer.cpp +++ b/src/framework/graphics/indexbuffer.cpp @@ -38,6 +38,9 @@ bool IndexBuffer::Initialize(GraphicsDevice *graphicsDevice, uint numIndices, BU Resize(numIndices); + if (graphicsDevice != NULL) + CreateOnGpu(); + return true; } @@ -60,9 +63,15 @@ bool IndexBuffer::Initialize(GraphicsDevice *graphicsDevice, const IndexBuffer * if (source->GetNumElements() == 0) return false; + if (!BufferObject::Initialize(graphicsDevice, BUFFEROBJECT_TYPE_INDEX, source->GetUsage())) + return false; + 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; }