#include <GL/glut.h>
#include <stdlib.h>
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT); //flush gl
glColor3f(1.0, 0.0, 0.0); //red line color
//outer pentagram, clockwise
glBegin(GL_LINE_LOOP);
glVertex2i(20,80);
glVertex2i(70,120);
glVertex2i(120,80);
glVertex2i(100,20);
glVertex2i(40,20);
glEnd();
//inner pentagram
glBegin(GL_LINE_LOOP);
glVertex2i(70,100);
glVertex2i(90,40);
glVertex2i(40,70);
glVertex2i(100,70);
glVertex2i(50,40);
glEnd();
//connectors
glBegin(GL_LINES);
//north
glVertex2i(70,120);
glVertex2i(70,100);
//north-east
glVertex2i(120,80);
glVertex2i(100,70);
//south-east
glVertex2i(100,20);
glVertex2i(90,40);
//south-west
glVertex2i(40,20);
glVertex2i(50,40);
//north-west
glVertex2i(20,80);
glVertex2i(40,70);
glEnd();
glFlush(); //force immidiate display
}
int main(int argc,char *argv[])
{
glutInit(&argc,argv); //prepare glut
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); //set the display mode
glutInitWindowSize (500, 500); //the size of the program window
glutInitWindowPosition (100, 100); //initial position for the window
glutCreateWindow ("points and lines"); //create window with a title
glClearColor(255,255,255,0.0); //background color
glMatrixMode (GL_PROJECTION); //2d envyronment
gluOrtho2D (0.0, 200.0, 0.0, 150.0); //matrix dimensions
glutDisplayFunc(display); //show thee actual program
glutMainLoop();
return EXIT_SUCCESS; //exit the program
}
Comments