const GLfloat M = 200;
GLfloat vertices[][2] = { {0.0,M} , {-M,0.0},
{0.0,-2*M} , {2*M,0.0}};
void interpolate()
{
GLfloat xMin = vertices[0][0];
GLfloat yMin = vertices[0][1];
GLfloat xMax = xMin;
GLfloat yMax = yMin;
for(int i=1; i<4; i++)
{
if(xMin >= vertices[i][0])
xMin = vertices[i][0];
else if(xMax >= vertices[i][0])
xMax = vertices[i][0];
if(yMin >= vertices[i][1])
yMin = vertices[i][1];
else if(yMax >= vertices[i][1])
yMax = vertices[i][1];
}
GLint width = (int)(xMax-xMin);
GLint height = (int)(yMax-yMin);
GLint array[(int)(xMax-xMin)][(int)(yMax-yMin)];
glReadBuffer(GL_FRONT_LEFT);
glReadPixels((int)xMin,(int)yMin, width, height, GL_RED, GL_INT, array);
GLint numberOfIntersections = 0;
for(int i=0; i<width; i++)
for(int j=0; j<height; j++)
{
printf("%i\n", array[i][j]);
}
}