CVertexBuffer: Make use of size_t in Reserve()

This commit is contained in:
Lioncash 2020-06-16 17:40:22 -04:00
parent 3d1ced47e2
commit 43596280c5
3 changed files with 11 additions and 8 deletions

View File

@ -133,7 +133,7 @@ uint16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, uint16 Start)
return AddVertex(rkVtx); return AddVertex(rkVtx);
} }
void CVertexBuffer::Reserve(uint16 Size) void CVertexBuffer::Reserve(size_t Size)
{ {
const size_t ReserveSize = mPositions.size() + Size; const size_t ReserveSize = mPositions.size() + Size;

View File

@ -28,7 +28,7 @@ public:
~CVertexBuffer(); ~CVertexBuffer();
uint16 AddVertex(const CVertex& rkVtx); uint16 AddVertex(const CVertex& rkVtx);
uint16 AddIfUnique(const CVertex& rkVtx, uint16 Start); uint16 AddIfUnique(const CVertex& rkVtx, uint16 Start);
void Reserve(uint16 Size); void Reserve(size_t Size);
void Clear(); void Clear();
void Buffer(); void Buffer();
void Bind(); void Bind();

View File

@ -410,16 +410,18 @@ void CDrawUtil::InitGrid()
const int kGridSize = 501; // must be odd const int kGridSize = 501; // must be odd
const float kGridSpacing = 1.f; const float kGridSpacing = 1.f;
int MinIdx = (kGridSize - 1) / -2; const int MinIdx = (kGridSize - 1) / -2;
int MaxIdx = (kGridSize - 1) / 2; const int MaxIdx = (kGridSize - 1) / 2;
mGridVertices.emplace(); mGridVertices.emplace();
mGridVertices->SetVertexDesc(EVertexAttribute::Position); mGridVertices->SetVertexDesc(EVertexAttribute::Position);
mGridVertices->Reserve(kGridSize * 4); mGridVertices->Reserve(static_cast<size_t>(kGridSize * 4));
for (int32 i = MinIdx; i <= MaxIdx; i++) 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(MinIdx * kGridSpacing, i * kGridSpacing, 0.0f));
mGridVertices->AddVertex(CVector3f(MaxIdx * kGridSpacing, i * kGridSpacing, 0.0f)); mGridVertices->AddVertex(CVector3f(MaxIdx * kGridSpacing, i * kGridSpacing, 0.0f));
mGridVertices->AddVertex(CVector3f(i * kGridSpacing, MinIdx * 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, MinIdx * kGridSpacing, 0.0f));
mGridVertices->AddVertex(CVector3f(0, MaxIdx * kGridSpacing, 0.0f)); mGridVertices->AddVertex(CVector3f(0, MaxIdx * kGridSpacing, 0.0f));
int NumIndices = kGridSize * 4; const auto NumIndices = static_cast<size_t>(kGridSize * 4);
mGridIndices.Reserve(NumIndices); 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); mGridIndices.SetPrimitiveType(GL_LINES);
} }