setPrimitiveType method
How the following draws assemble their vertices.
Strips and points are capabilities, since 1.0.0-rc.1:
PrimitiveType.triangleStrip and PrimitiveType.lineStrip need
DeviceFeature.primitiveStrips, PrimitiveType.point needs
DeviceFeature.pointPrimitives, and triangle and line lists need
nothing. A backend calls PrimitiveTypeFeatures.checkFeatures here, so
a topology it lacks is refused by name from this call, before a draw.
Every backend in this repository that draws lists both.
Primitive restart is always on for strips, on every backend that
lists primitiveStrips: an all-ones index (IndexTypeFeatures.restartIndex)
in an indexed strip ends it, and the next index starts a new one —
WebGPU's rule, and WebGL2's fixed-index restart. A list has no restart.
What the contract also promises is that a backend never assembles one primitive as another, because three points drawn as a triangle is a picture nobody asked for and no error anywhere.
Held by the conformance check
every primitive type is assembled as itself or refused, which draws all
five and compares how much each one painted, and draws a strip through a
restart.
Implementation
@override
void setPrimitiveType(PrimitiveType type) {
primitiveType = type;
commands.add(RecordedPrimitiveType(type));
}