From f216df7d0f60496304f11572c077f2b275dbdde6 Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Wed, 12 Jan 2022 12:10:00 +0000 Subject: [PATCH] LibSoftGPU: Don't render triangle strip if there's less than 3 vertices 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. --- Userland/Libraries/LibSoftGPU/Device.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp index 07714c3dca..d2153d69cc 100644 --- a/Userland/Libraries/LibSoftGPU/Device.cpp +++ b/Userland/Libraries/LibSoftGPU/Device.cpp @@ -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);