Skip to content

Commit

Permalink
LibSoftGPU: Don't render triangle strip if there's less than 3 vertices
Browse files Browse the repository at this point in the history
If there's less than 3 vertices, we cannot do triangle strip otherwise
we will go out-of-bounds of the vertices vector.

Required for Half-Life, which sometimes submits 0 vertices for triangle
strip when drawing the electric disks around the pillars in Xen.
  • Loading branch information
Lubrsi authored and linusg committed Jan 12, 2022
1 parent b397db9 commit f216df7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Userland/Libraries/LibSoftGPU/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
}
} else if (primitive_type == PrimitiveType::TriangleStrip) {
Triangle triangle;
if (vertices.size() < 3)
return;
for (size_t i = 0; i < vertices.size() - 2; i++) {
if (i % 2 == 0) {
triangle.vertices[0] = vertices.at(i);
Expand Down

0 comments on commit f216df7

Please sign in to comment.