Home › Forums › GAMES在线课程(现代计算机图形学入门)讨论区 › 作业2绘图舍入的bug › Reply To: 作业2绘图舍入的bug
你看这样行不
void rst::rasterizer::set_pixel(const Eigen::Vector3f &point, const Eigen::Vector3f &color)
{
// old index: auto ind = point.y() + point.x() * width;
int j = round(point.y());
int i = round(point.x());
if (j < 0 || j > height - 1)
return;
if (i < 0 || i > width - 1)
return;
// auto ind = (height - 1 - round(point.y())) * width + round(point.x());
auto ind = (height - 1 - j) * width + i;
frame_buf[ind] = color;
}