Original Post
I have a software rasterizer up and running and it works except for a small problem. When I render the faces to the buffer in the system memory I have lines that are about one pixel thick randomly showing up between the faces. I was thinking of adding one pixel to the end of each scanline but I really dont like the idea.
// Here Code to Scan Convert the Top of the Face
if(MY != TY)
{
const int MYminusTY = MY-TY;
const int BYminusTY = BY-TY;
const int slopeMX = ((MX-TX)<<16)/MYminusTY;
const int slopeBX = ((BX-TX)<<16)/BYminusTY;
const float slopeMZ = (MZ-TZ)/float(MYminusTY);
const float slopeBZ = (BZ-TZ)/float(BYminusTY);
if(slopeMX > slopeBX)
{
FillNormalTop(MYminusTY, TX, TY, TZ, slopeBX, slopeBZ,
slopeMX, slopeMZ);
}
else
{
FillNormalTop(MYminusTY, TX, TY, TZ, slopeMX, slopeMZ,
slopeBX, slopeBZ);
}
}
else if(MY != m_Hieght)
{
m_SetLineY = MY;
if(MX < TX)
{
m_SetLineX1 = MX;
m_SetLineX2 = TX;
m_SetLineZ1 = MZ;
m_SetLineZSlope = 0.0f;
const float Denom = (m_SetLineX1-m_SetLineX2);
m_SetLineZSlope = (m_SetLineZ1-TZ)/Denom;
(this->*m_LineSet)(m_RenderScanLine[MY]);
}
else
{
m_SetLineX1 = TX;
m_SetLineX2 = MX;
m_SetLineZ1 = TZ;
const float Denom = (m_SetLineX1-m_SetLineX2);
if(Denom != 0.0f)
{
m_SetLineZSlope = (m_SetLineZ1-MZ)/Denom;
(this->*m_LineSet)(m_RenderScanLine[MY]);
}
}
}
// Heres the Fill Normal Top Function
FillNormalTop(int Levelcount, const int Topx, const int Topy,
const float Topz, const int Leftdxdy, const float Leftdzdy,
const int Rightdxdy, const float Rightdzdy)
{
const int RoundUp = (1<<16)/2;
int LeftX = Topx<<16;
int RightX = LeftX;
float RightZ = Topz;
float LeftZ = Topz;
m_SetLineY = Topy;
Scanline** ScanLine = m_RenderScanLine+Topy;
while(Levelcount--)
{
m_SetLineX1 = (LeftX+RoundUp) >> 16;
m_SetLineX2 = (RightX+RoundUp) >> 16;
m_SetLineZ1 = LeftZ;
m_SetLineZSlope = (LeftZ-RightZ)/(m_SetLineX1
m_SetLineX2);
(this->*m_LineSet)(*ScanLine);
LeftX += Leftdxdy;
RightX += Rightdxdy;
LeftZ += Leftdzdy;
RightZ += Rightdzdy;
m_SetLineY++;
ScanLine++;
}
}