Browse Source

Eliminate more duplication of API-independent index / vertex buffer code.

Lasse Öörni 9 years ago
parent
commit
6775038a44

+ 0 - 33
Source/Urho3D/Graphics/Direct3D11/D3D11IndexBuffer.cpp

@@ -53,39 +53,6 @@ void IndexBuffer::Release()
     URHO3D_SAFE_RELEASE(object_.ptr_);
 }
 
-void IndexBuffer::SetShadowed(bool enable)
-{
-    // If no graphics subsystem, can not disable shadowing
-    if (!graphics_)
-        enable = true;
-
-    if (enable != shadowed_)
-    {
-        if (enable && indexCount_ && indexSize_)
-            shadowData_ = new unsigned char[indexCount_ * indexSize_];
-        else
-            shadowData_.Reset();
-
-        shadowed_ = enable;
-    }
-}
-
-bool IndexBuffer::SetSize(unsigned indexCount, bool largeIndices, bool dynamic)
-{
-    Unlock();
-
-    dynamic_ = dynamic;
-    indexCount_ = indexCount;
-    indexSize_ = (unsigned)(largeIndices ? sizeof(unsigned) : sizeof(unsigned short));
-
-    if (shadowed_ && indexCount_ && indexSize_)
-        shadowData_ = new unsigned char[indexCount_ * indexSize_];
-    else
-        shadowData_.Reset();
-
-    return Create();
-}
-
 bool IndexBuffer::SetData(const void* data)
 {
     if (!data)

+ 0 - 42
Source/Urho3D/Graphics/Direct3D11/D3D11VertexBuffer.cpp

@@ -58,46 +58,6 @@ void VertexBuffer::Release()
     URHO3D_SAFE_RELEASE(object_.ptr_);
 }
 
-void VertexBuffer::SetShadowed(bool enable)
-{
-    // If no graphics subsystem, can not disable shadowing
-    if (!graphics_)
-        enable = true;
-
-    if (enable != shadowed_)
-    {
-        if (enable && vertexSize_ && vertexCount_)
-            shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
-        else
-            shadowData_.Reset();
-
-        shadowed_ = enable;
-    }
-}
-
-bool VertexBuffer::SetSize(unsigned vertexCount, unsigned elementMask, bool dynamic)
-{
-    return SetSize(vertexCount, GetElements(elementMask), dynamic);
-}
-
-bool VertexBuffer::SetSize(unsigned vertexCount, const PODVector<VertexElement>& elements, bool dynamic)
-{
-    Unlock();
-
-    dynamic_ = dynamic;
-    vertexCount_ = vertexCount;
-    elements_ = elements;
-
-    UpdateOffsets();
-
-    if (shadowed_ && vertexCount_ && vertexSize_)
-        shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
-    else
-        shadowData_.Reset();
-
-    return Create();
-}
-
 bool VertexBuffer::SetData(const void* data)
 {
     if (!data)
@@ -273,8 +233,6 @@ void VertexBuffer::Unlock()
     }
 }
 
-
-
 bool VertexBuffer::Create()
 {
     Release();

+ 0 - 33
Source/Urho3D/Graphics/Direct3D9/D3D9IndexBuffer.cpp

@@ -64,39 +64,6 @@ void IndexBuffer::Release()
     URHO3D_SAFE_RELEASE(object_.ptr_);
 }
 
-void IndexBuffer::SetShadowed(bool enable)
-{
-    // If no graphics subsystem, can not disable shadowing
-    if (!graphics_)
-        enable = true;
-
-    if (enable != shadowed_)
-    {
-        if (enable && indexCount_ && indexSize_)
-            shadowData_ = new unsigned char[indexCount_ * indexSize_];
-        else
-            shadowData_.Reset();
-
-        shadowed_ = enable;
-    }
-}
-
-bool IndexBuffer::SetSize(unsigned indexCount, bool largeIndices, bool dynamic)
-{
-    Unlock();
-
-    indexCount_ = indexCount;
-    indexSize_ = (unsigned)(largeIndices ? sizeof(unsigned) : sizeof(unsigned short));
-    dynamic_ = dynamic;
-
-    if (shadowed_ && indexCount_ && indexSize_)
-        shadowData_ = new unsigned char[indexCount_ * indexSize_];
-    else
-        shadowData_.Reset();
-
-    return Create();
-}
-
 bool IndexBuffer::SetData(const void* data)
 {
     if (!data)

+ 0 - 40
Source/Urho3D/Graphics/Direct3D9/D3D9VertexBuffer.cpp

@@ -69,46 +69,6 @@ void VertexBuffer::Release()
     URHO3D_SAFE_RELEASE(object_.ptr_);
 }
 
-void VertexBuffer::SetShadowed(bool enable)
-{
-    // If no graphics subsystem, can not disable shadowing
-    if (!graphics_)
-        enable = true;
-
-    if (enable != shadowed_)
-    {
-        if (enable && vertexSize_ && vertexCount_)
-            shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
-        else
-            shadowData_.Reset();
-
-        shadowed_ = enable;
-    }
-}
-
-bool VertexBuffer::SetSize(unsigned vertexCount, unsigned elementMask, bool dynamic)
-{
-    return SetSize(vertexCount, GetElements(elementMask), dynamic);
-}
-
-bool VertexBuffer::SetSize(unsigned vertexCount, const PODVector<VertexElement>& elements, bool dynamic)
-{
-    Unlock();
-
-    vertexCount_ = vertexCount;
-    elements_ = elements;
-    dynamic_ = dynamic;
-
-    UpdateOffsets();
-
-    if (shadowed_ && vertexCount_ && vertexSize_)
-        shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
-    else
-        shadowData_.Reset();
-
-    return Create();
-}
-
 bool VertexBuffer::SetData(const void* data)
 {
     if (!data)

+ 33 - 0
Source/Urho3D/Graphics/IndexBuffer.cpp

@@ -55,6 +55,39 @@ IndexBuffer::~IndexBuffer()
     Release();
 }
 
+void IndexBuffer::SetShadowed(bool enable)
+{
+    // If no graphics subsystem, can not disable shadowing
+    if (!graphics_)
+        enable = true;
+
+    if (enable != shadowed_)
+    {
+        if (enable && indexCount_ && indexSize_)
+            shadowData_ = new unsigned char[indexCount_ * indexSize_];
+        else
+            shadowData_.Reset();
+
+        shadowed_ = enable;
+    }
+}
+
+bool IndexBuffer::SetSize(unsigned indexCount, bool largeIndices, bool dynamic)
+{
+    Unlock();
+
+    indexCount_ = indexCount;
+    indexSize_ = (unsigned)(largeIndices ? sizeof(unsigned) : sizeof(unsigned short));
+    dynamic_ = dynamic;
+
+    if (shadowed_ && indexCount_ && indexSize_)
+        shadowData_ = new unsigned char[indexCount_ * indexSize_];
+    else
+        shadowData_.Reset();
+
+    return Create();
+}
+
 bool IndexBuffer::GetUsedVertexRange(unsigned start, unsigned count, unsigned& minVertex, unsigned& vertexCount)
 {
     if (!shadowData_)

+ 0 - 33
Source/Urho3D/Graphics/OpenGL/OGLIndexBuffer.cpp

@@ -72,39 +72,6 @@ void IndexBuffer::Release()
     }
 }
 
-void IndexBuffer::SetShadowed(bool enable)
-{
-    // If no graphics subsystem, can not disable shadowing
-    if (!graphics_)
-        enable = true;
-
-    if (enable != shadowed_)
-    {
-        if (enable && indexCount_ && indexSize_)
-            shadowData_ = new unsigned char[indexCount_ * indexSize_];
-        else
-            shadowData_.Reset();
-
-        shadowed_ = enable;
-    }
-}
-
-bool IndexBuffer::SetSize(unsigned indexCount, bool largeIndices, bool dynamic)
-{
-    Unlock();
-
-    dynamic_ = dynamic;
-    indexCount_ = indexCount;
-    indexSize_ = (unsigned)(largeIndices ? sizeof(unsigned) : sizeof(unsigned short));
-
-    if (shadowed_ && indexCount_ && indexSize_)
-        shadowData_ = new unsigned char[indexCount_ * indexSize_];
-    else
-        shadowData_.Reset();
-
-    return Create();
-}
-
 bool IndexBuffer::SetData(const void* data)
 {
     if (!data)

+ 0 - 40
Source/Urho3D/Graphics/OpenGL/OGLVertexBuffer.cpp

@@ -75,46 +75,6 @@ void VertexBuffer::Release()
     }
 }
 
-void VertexBuffer::SetShadowed(bool enable)
-{
-    // If no graphics subsystem, can not disable shadowing
-    if (!graphics_)
-        enable = true;
-
-    if (enable != shadowed_)
-    {
-        if (enable && vertexSize_ && vertexCount_)
-            shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
-        else
-            shadowData_.Reset();
-
-        shadowed_ = enable;
-    }
-}
-
-bool VertexBuffer::SetSize(unsigned vertexCount, unsigned elementMask, bool dynamic)
-{
-    return SetSize(vertexCount, GetElements(elementMask), dynamic);
-}
-
-bool VertexBuffer::SetSize(unsigned vertexCount, const PODVector<VertexElement>& elements, bool dynamic)
-{
-    Unlock();
-
-    vertexCount_ = vertexCount;
-    elements_ = elements;
-    dynamic_ = dynamic;
-
-    UpdateOffsets();
-
-    if (shadowed_ && vertexCount_ && vertexSize_)
-        shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
-    else
-        shadowData_.Reset();
-
-    return Create();
-}
-
 bool VertexBuffer::SetData(const void* data)
 {
     if (!data)

+ 40 - 0
Source/Urho3D/Graphics/VertexBuffer.cpp

@@ -57,6 +57,46 @@ VertexBuffer::~VertexBuffer()
     Release();
 }
 
+void VertexBuffer::SetShadowed(bool enable)
+{
+    // If no graphics subsystem, can not disable shadowing
+    if (!graphics_)
+        enable = true;
+
+    if (enable != shadowed_)
+    {
+        if (enable && vertexSize_ && vertexCount_)
+            shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
+        else
+            shadowData_.Reset();
+
+        shadowed_ = enable;
+    }
+}
+
+bool VertexBuffer::SetSize(unsigned vertexCount, unsigned elementMask, bool dynamic)
+{
+    return SetSize(vertexCount, GetElements(elementMask), dynamic);
+}
+
+bool VertexBuffer::SetSize(unsigned vertexCount, const PODVector<VertexElement>& elements, bool dynamic)
+{
+    Unlock();
+
+    vertexCount_ = vertexCount;
+    elements_ = elements;
+    dynamic_ = dynamic;
+
+    UpdateOffsets();
+
+    if (shadowed_ && vertexCount_ && vertexSize_)
+        shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
+    else
+        shadowData_.Reset();
+
+    return Create();
+}
+
 void VertexBuffer::UpdateOffsets()
 {
     unsigned elementOffset = 0;