summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/IndexGenerator.cpp
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2009-09-29 18:27:41 +0000
committerhrydgard <hrydgard@gmail.com>2009-09-29 18:27:41 +0000
commite6b30e574e21e8a317839b6f08852441c80ce047 (patch)
tree1070e1472066189bfc2548f7796c438de95c9141 /Source/Core/VideoCommon/Src/IndexGenerator.cpp
parent4d5eba2ec979455b62139436d8310a7e7c8efd7b (diff)
Let's try rodolfo's fix of 4322
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4343 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon/Src/IndexGenerator.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/IndexGenerator.cpp149
1 files changed, 149 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/Src/IndexGenerator.cpp b/Source/Core/VideoCommon/Src/IndexGenerator.cpp
index 407fbe6579..8390e7c306 100644
--- a/Source/Core/VideoCommon/Src/IndexGenerator.cpp
+++ b/Source/Core/VideoCommon/Src/IndexGenerator.cpp
@@ -145,3 +145,152 @@ void IndexGenerator::AddPoints(int numVerts)
numPrims += numVerts;
adds++;
}
+
+
+
+ //Init
+void IndexGenerator2::Start(unsigned short *Triangleptr,unsigned short *Lineptr,unsigned short *Pointptr)
+{
+ Tptr = Triangleptr;
+ Lptr = Lineptr;
+ Pptr = Pointptr;
+ index = 0;
+ numT = 0;
+ numL = 0;
+ numP = 0;
+ Tadds = 0;
+ Ladds = 0;
+ Padds = 0;
+ TindexLen = 0;
+ LindexLen = 0;
+ PindexLen = 0;
+ LastTPrimitive = None;
+ LastLPrimitive = None;
+}
+// Triangles
+void IndexGenerator2::AddList(int numVerts)
+{
+ int numTris = numVerts / 3;
+ if (numTris <= 0) return;
+ for (int i = 0; i < numTris; i++)
+ {
+ *Tptr++ = index+i*3;
+ *Tptr++ = index+i*3+1;
+ *Tptr++ = index+i*3+2;
+ }
+ TindexLen += numVerts;
+ index += numVerts;
+ numT += numTris;
+ Tadds++;
+ LastTPrimitive = List;
+}
+
+void IndexGenerator2::AddStrip(int numVerts)
+{
+ int numTris = numVerts - 2;
+ if (numTris <= 0) return;
+ bool wind = false;
+ for (int i = 0; i < numTris; i++)
+ {
+ *Tptr++ = index+i;
+ *Tptr++ = index+i+(wind?2:1);
+ *Tptr++ = index+i+(wind?1:2);
+ wind = !wind;
+ }
+ TindexLen += numTris * 3;
+ index += numVerts;
+ numT += numTris;
+ Tadds++;
+ LastTPrimitive = Strip;
+}
+void IndexGenerator2::AddFan(int numVerts)
+{
+ int numTris = numVerts - 2;
+ if (numTris <= 0) return;
+ for (int i = 0; i < numTris; i++)
+ {
+ *Tptr++ = index;
+ *Tptr++ = index+i+1;
+ *Tptr++ = index+i+2;
+ }
+ TindexLen += numTris * 3;
+ index += numVerts;
+ numT += numTris;
+ Tadds++;
+ LastTPrimitive = Fan;
+}
+
+void IndexGenerator2::AddQuads(int numVerts)
+{
+ int numTris = (numVerts/4)*2;
+ if (numTris <= 0) return;
+ for (int i = 0; i < numTris / 2; i++)
+ {
+ *Tptr++ = index+i*4;
+ *Tptr++ = index+i*4+1;
+ *Tptr++ = index+i*4+3;
+ *Tptr++ = index+i*4+1;
+ *Tptr++ = index+i*4+2;
+ *Tptr++ = index+i*4+3;
+ }
+ TindexLen += numTris * 3;
+ index += numVerts;
+ numT += numTris;
+ Tadds++;
+ LastTPrimitive = List;
+}
+
+
+//Lines
+void IndexGenerator2::AddLineList(int numVerts)
+{
+ int numLines= numVerts / 2;
+ if (numLines <= 0) return;
+ for (int i = 0; i < numLines; i++)
+ {
+ *Lptr++ = index+i*2;
+ *Lptr++ = index+i*2+1;
+ }
+ LindexLen += numVerts;
+ index += numVerts;
+ numL += numLines;
+ Ladds++;
+ LastLPrimitive = List;
+}
+
+void IndexGenerator2::AddLineStrip(int numVerts)
+{
+ int numLines = numVerts - 1;
+ if (numLines <= 0) return;
+ for (int i = 0; i < numLines; i++)
+ {
+ *Lptr++ = index+i;
+ *Lptr++ = index+i+1;
+ }
+ LindexLen += numLines * 2;
+ index += numVerts;
+ numL += numLines;
+ Ladds++;
+ LastLPrimitive = Strip;
+}
+
+
+
+//Points
+void IndexGenerator2::AddPoints(int numVerts)
+{
+ for (int i = 0; i < numVerts; i++)
+ {
+ *Pptr++ = index+i;
+ }
+ index += numVerts;
+ numP += numVerts;
+ PindexLen+=numVerts;
+ Padds++;
+}
+
+
+
+
+
+