All pastes #907476 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-02-17 17:16 UTC
rendered paste body
// do 2 rows at a time, add degenerate triangle at the end of each row
// this is for triangle strip, primitive count = totalIndexCount - 2

index0 = 0; // current row
index1 = width; // next row

currentIndex = 0;

totalIndexCount = 2 * ((height - 2) / 2) * (2 * width + 1);

for (int row = 0; row < (height - 2); row += 2)
{
   for(int column = 0; column < width; column++)
   {
      indices[currentIndex++] = index0;
      indices[currentIndex++] = index1;
   }

   // degenerate
   indices[currentIndex++] = index1 - 1;
   indices[currentIndex++] = index1 - 1;

   index0 += width;
   index1 += width;

   for(int column = 0; column < width; column++)
   {
      indices[currentIndex++] = --index1;
      indices[currentIndex++] = --index0;
   }

   index0 += width;
   index1 += width;
}