diff options
| author | Pokechu22 <Pokechu022@gmail.com> | 2020-12-22 15:00:40 -0800 |
|---|---|---|
| committer | Pokechu22 <Pokechu022@gmail.com> | 2021-02-13 15:59:40 -0800 |
| commit | fcd3efa1ae92e0d3343a4fdb904b3400747a38c7 (patch) | |
| tree | 1b26d57dcac239a54ddd2585e3c1a3a048b8021a /Source/Core/VideoBackends/Software/Clipper.cpp | |
| parent | 8e348b87e939510439af3f506be1f29b5694cbf1 (diff) | |
Software: Implement points
Diffstat (limited to 'Source/Core/VideoBackends/Software/Clipper.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Software/Clipper.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Source/Core/VideoBackends/Software/Clipper.cpp b/Source/Core/VideoBackends/Software/Clipper.cpp index 1378b57472..4c4e0db52d 100644 --- a/Source/Core/VideoBackends/Software/Clipper.cpp +++ b/Source/Core/VideoBackends/Software/Clipper.cpp @@ -415,6 +415,53 @@ void ProcessLine(OutputVertexData* lineV0, OutputVertexData* lineV1) } } +static void CopyPointVertex(OutputVertexData* dst, const OutputVertexData* src, bool px, bool py) +{ + const float point_radius = bpmem.lineptwidth.pointsize / 12.0f; + + dst->projectedPosition = src->projectedPosition; + dst->screenPosition.x = src->screenPosition.x + (px ? 1 : -1) * point_radius; + dst->screenPosition.y = src->screenPosition.y + (py ? 1 : -1) * point_radius; + dst->screenPosition.z = src->screenPosition.z; + + dst->normal = src->normal; + dst->color = src->color; + + dst->texCoords = src->texCoords; + + const float point_offset = LINE_PT_TEX_OFFSETS[bpmem.lineptwidth.pointoff]; + if (point_offset != 0) + { + for (u32 coord_num = 0; coord_num < xfmem.numTexGen.numTexGens; coord_num++) + { + const auto coord_info = bpmem.texcoords[coord_num]; + if (coord_info.s.point_offset) + { + if (px) + dst->texCoords[coord_num].x += (coord_info.s.scale_minus_1 + 1) * point_offset; + if (py) + dst->texCoords[coord_num].y += (coord_info.t.scale_minus_1 + 1) * point_offset; + } + } + } +} + +void ProcessPoint(OutputVertexData* center) +{ + // TODO: This isn't actually doing any clipping + PerspectiveDivide(center); + + OutputVertexData ll, lr, ul, ur; + + CopyPointVertex(&ll, center, false, false); + CopyPointVertex(&lr, center, true, false); + CopyPointVertex(&ur, center, true, true); + CopyPointVertex(&ul, center, false, true); + + Rasterizer::DrawTriangleFrontFace(&ll, &ul, &lr); + Rasterizer::DrawTriangleFrontFace(&ur, &lr, &ul); +} + bool CullTest(const OutputVertexData* v0, const OutputVertexData* v1, const OutputVertexData* v2, bool& backface) { |
