From 3c70015da77cbaf8df6d0ec130942aaef5854c90 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Tue, 11 Jun 2019 03:10:32 +0200 Subject: [PATCH] software renderer: fix rendering of line polygons. fixes #350 --- src/GPU3D.h | 2 ++ src/GPU3D_Soft.cpp | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/GPU3D.h b/src/GPU3D.h index 4e7c01a9..e1152615 100644 --- a/src/GPU3D.h +++ b/src/GPU3D.h @@ -66,6 +66,8 @@ typedef struct bool IsShadowMask; bool IsShadow; + int Type; // 0=polygon 1=horizontal line 2=vertical line 3=diagonal line 4=point + u32 VTop, VBottom; // vertex indices s32 YTop, YBottom; // Y coords s32 XTop, XBottom; // associated X coords diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp index 932b5d41..193d1983 100644 --- a/src/GPU3D_Soft.cpp +++ b/src/GPU3D_Soft.cpp @@ -1367,7 +1367,7 @@ void RenderPolygonScanline(RendererPolygon* rp, s32 y) // right vertical edges are pushed 1px to the left // edges are always filled if antialiasing/edgemarking are enabled or if the pixels are translucent - if (wireframe || (RenderDispCnt & (1<<5))) + if (wireframe || (RenderDispCnt & ((1<<4)|(1<<5)))) { l_filledge = true; r_filledge = true; @@ -1466,6 +1466,8 @@ void RenderPolygonScanline(RendererPolygon* rp, s32 y) if (xcov == 0x3FF) xcov = 0; } + if (!l_filledge) x = std::min(xlimit, xend-r_edgelen+1); + else for (; x < xlimit; x++) { u32 pixeladdr = FirstPixelOffset + (y*ScanlineWidth) + x; @@ -1538,8 +1540,6 @@ void RenderPolygonScanline(RendererPolygon* rp, s32 y) AttrBuffer[pixeladdr+BufferSize] = AttrBuffer[pixeladdr]; } } - else if (!l_filledge) - continue; DepthBuffer[pixeladdr] = z; ColorBuffer[pixeladdr] = color; @@ -1561,8 +1561,10 @@ void RenderPolygonScanline(RendererPolygon* rp, s32 y) xlimit = xend-r_edgelen+1; if (xlimit > xend+1) xlimit = xend+1; if (xlimit > 256) xlimit = 256; + if (wireframe && !edge) x = xlimit; - else for (; x < xlimit; x++) + else + for (; x < xlimit; x++) { u32 pixeladdr = FirstPixelOffset + (y*ScanlineWidth) + x; u32 dstattr = AttrBuffer[pixeladdr]; @@ -1636,6 +1638,7 @@ void RenderPolygonScanline(RendererPolygon* rp, s32 y) if (xcov == 0x3FF) xcov = 0; } + if (r_filledge) for (; x < xlimit; x++) { u32 pixeladdr = FirstPixelOffset + (y*ScanlineWidth) + x; @@ -1708,8 +1711,6 @@ void RenderPolygonScanline(RendererPolygon* rp, s32 y) AttrBuffer[pixeladdr+BufferSize] = AttrBuffer[pixeladdr]; } } - else if (!r_filledge) - continue; DepthBuffer[pixeladdr] = z; ColorBuffer[pixeladdr] = color;