/* * simple2.c -- Angel, OpenGL: A Primer, p. 23 * stipple applied to line-loop variant: p. 26,27 */ #include void display() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0,1.0,0.0); glLineWidth(3.0); glLineStipple(3,0xcccc); glBegin(GL_LINE_LOOP); glVertex2f(-0.5,-0.5); glVertex2f(-0.5,0.5); glVertex2f(0.5,0.5); glVertex2f(0.5,-0.5); glEnd(); glFlush(); } void init() { glClearColor(0.0,0.0,0.0,0.0); glColor3f(1.0,1.0,1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-1.0,1.0,-1.0,1.0); glEnable(GL_LINE_STIPPLE); } int main(int argc,char *argv[]) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(0,0); glutCreateWindow("simple"); glutDisplayFunc(display); init(); glutMainLoop(); }