-1

给定代码(取自C++ 中的扫描线填充 OpenGL/GLUT 算法):

void scanfill(float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4)
{
    int le[500],re[500],i,j;

    for(i=0;i<500;i++)
        le[i]=500,re[i]=0;

    edgedetect(x1,y1,x2,y2,le,re);
    edgedetect(x2,y2,x3,y3,le,re);
    edgedetect(x3,y3,x4,y4,le,re);
    edgedetect(x4,y4,x1,y1,le,re);

    for(j=0;j<500;j++)
    {
        if(le[j]<=re[j])
            for(i=le[j];i<re[j];i++)
                draw_pixel(i,j);
    }
}

re[500]le[500]数组是什么?为什么是500?

4

1 回答 1

3

它们是左右边缘缓冲区。它们存储要在每个水平扫描线上填充的最小和最大 X 坐标。

500 只是 中指定的窗口高度glutInitWindowSize(500,500);

于 2014-12-02T13:46:51.877 回答