forked from ShuriZma/suyu
1
0
Fork 0

Pica/PrimitiveAssembly: Implement triangle strips.

This commit is contained in:
Tony Wasserka 2014-12-07 00:26:48 +01:00
parent 346012f29e
commit cd322e328e
2 changed files with 16 additions and 8 deletions

View File

@ -30,20 +30,27 @@ void PrimitiveAssembler<VertexType>::SubmitVertex(VertexType& vtx, TriangleHandl
}
break;
case Regs::TriangleTopology::Strip:
case Regs::TriangleTopology::Fan:
if (buffer_index == 2) {
buffer_index = 0;
if (strip_ready) {
// TODO: Should be "buffer[0], buffer[1], vtx" instead!
// Not quite sure why we need this order for things to show up properly.
// Maybe a bug in the rasterizer?
triangle_handler(buffer[1], buffer[0], vtx);
}
buffer[buffer_index] = vtx;
triangle_handler(buffer[0], buffer[1], vtx);
buffer[1] = vtx;
} else {
buffer[buffer_index++] = vtx;
if (topology == Regs::TriangleTopology::Strip) {
strip_ready |= (buffer_index == 1);
buffer_index = !buffer_index;
} else if (topology == Regs::TriangleTopology::Fan) {
buffer_index = 1;
strip_ready = true;
}
break;
default:
LOG_ERROR(Render_Software, "Unknown triangle topology %x:", (int)topology);
LOG_ERROR(HW_GPU, "Unknown triangle topology %x:", (int)topology);
break;
}
}

View File

@ -37,6 +37,7 @@ private:
int buffer_index;
VertexType buffer[2];
bool strip_ready = false;
};