Commits

Cliff Biffle  committed bcac29e

Triangle renderer now leaves holes where the data has holes. This is slightly trickier for a strip-based render than for the separate-quads renderer, because skipping any single point will reverse the winding order.

  • Participants
  • Parent commits 14c5dbb

Comments (0)

Files changed (1)

File KVDepthView.m

   glPolygonMode(GL_FRONT, mode);
   for (int y = 0; y < 479; y++) {
     glBegin(GL_TRIANGLE_STRIP);
+    BOOL inStrip = YES;
     for (int x = 0; x < 640; x++) {
+      
       for (int step = 0; step < 2; step++) {
         GLfloat d = depths[(y + step) * 640 + x];
+        
+        if (d < 0.1F) {
+          // Hole in the data.
+          if (inStrip) {
+            glEnd();
+            inStrip = NO;
+          }
+          // Break out of step loop to ensure that we always start
+          // each vertical edge at the *top*.  Otherwise the winding
+          // gets hosed.
+          break;
+        } else {
+          // Valid data.
+          if (!inStrip) {
+            glBegin(GL_TRIANGLE_STRIP);
+            inStrip = YES;
+          }
+        }
+        
         vec3f_t coord = correctPerspective(x, y + step, d);
         GLfloat color = 1.F - (d / 6.F);
         
         glVertex3fv(&coord.x);
       }
     }
-    glEnd();
+    if (inStrip) glEnd();
   }
 }