google / bigwheels

BigWheels is a cross-platform, API agnostic framework to build graphics applications.
Apache License 2.0
94 stars 37 forks source link

Require UINT32 type in Geometry::AppendIndicesU32 #490

Closed footballhead closed 4 months ago

footballhead commented 4 months ago

Unlike AppendIndex and friends, AppendIndicesU32 doesn't account for INDEX_TYPE_UNDEFINED. Consider:

Geometry geometry;
Geometry::Create(GeometryCreateInfo{}.IndexType(grfx::INDEX_TYPE_UNDEFINED).AddPosition(), &geometry);
std::array<uint32_t, 3> data = {0, 1, 2)
geometry.AppendIndicesU32(data.size(), data.data());
EXPECT_EQ(geometry.GetIndexBuffer()->GetSize(), 0);

This test would fail since the data would be written to the index buffer!

This seems like an oversight. The condition has been fixed and tests have been added.