c++ opengl scan line algorithm

1.5k Views Asked by At

Given the code (taken from Scan-line fill OpenGL/GLUT algorithm in C++):

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);
    }
}

What are the re[500] and le[500] arrays? And why 500?

1

There are 1 best solutions below

0
On BEST ANSWER

They are the left and right edge buffers. They store the minimum and maximum X coordinate to be filled on each horizontal scan line.

500 is just the height of the window as specified in glutInitWindowSize(500,500);.