summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSoftGPU
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2021-12-24 14:48:00 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-27 11:58:43 +0100
commit60fa921daa9dc1fe1d947beeb8c837558730bd34 (patch)
tree093d34881e10ee5ff76539342df366f7850123ee /Userland/Libraries/LibSoftGPU
parentb455e6ca0d84c73d28fc990975655a2158aea1b8 (diff)
downloadserenity-60fa921daa9dc1fe1d947beeb8c837558730bd34.zip
LibGL: Fix `GL_TRIANGLE_STRIP` rendering only half its triangles
According to the documentation, we should switch around vertices every other triangle to prevent front-face culling from removing them. This allows Tux in Tux Racer to render correctly.
Diffstat (limited to 'Userland/Libraries/LibSoftGPU')
-rw-r--r--Userland/Libraries/LibSoftGPU/Device.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp
index b77789f90b..45ec7fa84b 100644
--- a/Userland/Libraries/LibSoftGPU/Device.cpp
+++ b/Userland/Libraries/LibSoftGPU/Device.cpp
@@ -565,9 +565,15 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
} else if (primitive_type == PrimitiveType::TriangleStrip) {
Triangle triangle;
for (size_t i = 0; i < vertices.size() - 2; i++) {
- triangle.vertices[0] = vertices.at(i);
- triangle.vertices[1] = vertices.at(i + 1);
- triangle.vertices[2] = vertices.at(i + 2);
+ if (i % 2 == 0) {
+ triangle.vertices[0] = vertices.at(i);
+ triangle.vertices[1] = vertices.at(i + 1);
+ triangle.vertices[2] = vertices.at(i + 2);
+ } else {
+ triangle.vertices[0] = vertices.at(i + 1);
+ triangle.vertices[1] = vertices.at(i);
+ triangle.vertices[2] = vertices.at(i + 2);
+ }
m_triangle_list.append(triangle);
}
}