// Modified from one of the GLUT sample files by Mark Kilgard simple.c // uses default viewing volume from (-1, -1, -1) to (1, 1, 1) // uses orthographic projection #include #include using namespace std; // global variables int npts; void display(void) { int i, j; double x, y; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); // this is where the calculation and drawing take place for (j=0; j0.0) && (y>0.0)) glColor3f(0.0, 1.0, 1.0); else if ((x<0.0) && (y>0.0)) glColor3f(1.0, 1.0, 0.0); else if ((x<0.0) && (y<0.0)) glColor3f(1.0, 0.0, 1.0); else glColor3f(0.5, 0.7, 0.7); // draw point glVertex2f(x,y); } glEnd(); glFlush(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutCreateWindow("triangle"); glutDisplayFunc(display); cout << "How many points along each axis??"; cin >> npts; glutMainLoop(); return 0; }