I think there is a clipping bug in Rasterizer::DrawLine(..).
In both cases y equals ymax. That can't be good.
My suggestion should be something like...
- Code:
else if (code & 4)
{
// Top edge
x = p1.x + (p2.x - p1.x) * (ymax - p1.y) / (p2.y - p1.y);
y = ymax;
}
else if (code & 8)
{
// Bottom edge
x = p1.x + (p2.x - p1.x) * (ymin - p1.y) / (p2.y - p1.y);
y = ymax;
}
In both cases y equals ymax. That can't be good.
My suggestion should be something like...
- Code:
else if (code & 4)
{
// Top edge
//x = p1.x + (p2.x - p1.x) * (ymax - p1.y) / (p2.y - p1.y);
//y = ymax;
x = p1.x + (p2.x - p1.x) * (ymin - p1.y) / (p2.y - p1.y);
y = ymin;
}
else if (code & 8)
{
// Bottom edge
//x = p1.x + (p2.x - p1.x) * (ymin - p1.y) / (p2.y - p1.y);
x = p1.x + (p2.x - p1.x) * (ymax - p1.y) / (p2.y - p1.y);
y = ymax;
}