From 43596280c52e9b8c31edd23d011c574e8f392654 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 16 Jun 2020 17:40:22 -0400 Subject: [PATCH] CVertexBuffer: Make use of size_t in Reserve() --- src/Core/OpenGL/CVertexBuffer.cpp | 2 +- src/Core/OpenGL/CVertexBuffer.h | 2 +- src/Core/Render/CDrawUtil.cpp | 15 +++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Core/OpenGL/CVertexBuffer.cpp b/src/Core/OpenGL/CVertexBuffer.cpp index 1586adbb..89bb3f23 100644 --- a/src/Core/OpenGL/CVertexBuffer.cpp +++ b/src/Core/OpenGL/CVertexBuffer.cpp @@ -133,7 +133,7 @@ uint16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, uint16 Start) return AddVertex(rkVtx); } -void CVertexBuffer::Reserve(uint16 Size) +void CVertexBuffer::Reserve(size_t Size) { const size_t ReserveSize = mPositions.size() + Size; diff --git a/src/Core/OpenGL/CVertexBuffer.h b/src/Core/OpenGL/CVertexBuffer.h index d5a2460f..6caae385 100644 --- a/src/Core/OpenGL/CVertexBuffer.h +++ b/src/Core/OpenGL/CVertexBuffer.h @@ -28,7 +28,7 @@ public: ~CVertexBuffer(); uint16 AddVertex(const CVertex& rkVtx); uint16 AddIfUnique(const CVertex& rkVtx, uint16 Start); - void Reserve(uint16 Size); + void Reserve(size_t Size); void Clear(); void Buffer(); void Bind(); diff --git a/src/Core/Render/CDrawUtil.cpp b/src/Core/Render/CDrawUtil.cpp index 46b68941..5ad20a33 100644 --- a/src/Core/Render/CDrawUtil.cpp +++ b/src/Core/Render/CDrawUtil.cpp @@ -410,16 +410,18 @@ void CDrawUtil::InitGrid() const int kGridSize = 501; // must be odd const float kGridSpacing = 1.f; - int MinIdx = (kGridSize - 1) / -2; - int MaxIdx = (kGridSize - 1) / 2; + const int MinIdx = (kGridSize - 1) / -2; + const int MaxIdx = (kGridSize - 1) / 2; mGridVertices.emplace(); mGridVertices->SetVertexDesc(EVertexAttribute::Position); - mGridVertices->Reserve(kGridSize * 4); + mGridVertices->Reserve(static_cast(kGridSize * 4)); for (int32 i = MinIdx; i <= MaxIdx; i++) { - if (i == 0) continue; + if (i == 0) + continue; + mGridVertices->AddVertex(CVector3f(MinIdx * kGridSpacing, i * kGridSpacing, 0.0f)); mGridVertices->AddVertex(CVector3f(MaxIdx * kGridSpacing, i * kGridSpacing, 0.0f)); mGridVertices->AddVertex(CVector3f(i * kGridSpacing, MinIdx * kGridSpacing, 0.0f)); @@ -431,9 +433,10 @@ void CDrawUtil::InitGrid() mGridVertices->AddVertex(CVector3f(0, MinIdx * kGridSpacing, 0.0f)); mGridVertices->AddVertex(CVector3f(0, MaxIdx * kGridSpacing, 0.0f)); - int NumIndices = kGridSize * 4; + const auto NumIndices = static_cast(kGridSize * 4); mGridIndices.Reserve(NumIndices); - for (uint16 i = 0; i < NumIndices; i++) mGridIndices.AddIndex(i); + for (uint16 i = 0; i < NumIndices; i++) + mGridIndices.AddIndex(i); mGridIndices.SetPrimitiveType(GL_LINES); }