Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1: #include <GL/glut.h>
- 2: #include <stdlib.h>
- 3:
- 4:
- 5: void display(void)
- 6: {
- 7: glClear(GL_COLOR_BUFFER_BIT); //flush gl
- 8: glColor3f(1.0, 0.0, 0.0); //red line color
- 9:
- 10: //outer pentagram, clockwise
- 11: glBegin(GL_LINE_LOOP);
- 12: glVertex2i(20,80);
- 13: glVertex2i(70,120);
- 14: glVertex2i(120,80);
- 15: glVertex2i(100,20);
- 16: glVertex2i(40,20);
- 17: glEnd();
- 18:
- 19: //inner pentagram
- 20: glBegin(GL_LINE_LOOP);
- 21: glVertex2i(70,100);
- 22: glVertex2i(90,40);
- 23: glVertex2i(40,70);
- 24: glVertex2i(100,70);
- 25: glVertex2i(50,40);
- 26: glEnd();
- 27:
- 28: //connectors
- 29: glBegin(GL_LINES);
- 30: //north
- 31: glVertex2i(70,120);
- 32: glVertex2i(70,100);
- 33: //north-east
- 34: glVertex2i(120,80);
- 35: glVertex2i(100,70);
- 36: //south-east
- 37: glVertex2i(100,20);
- 38: glVertex2i(90,40);
- 39: //south-west
- 40: glVertex2i(40,20);
- 41: glVertex2i(50,40);
- 42: //north-west
- 43: glVertex2i(20,80);
- 44: glVertex2i(40,70);
- 45: glEnd();
- 46:
- 47: glFlush(); //force immidiate display
- 48: }
- 49:
- 50: int main(int argc,char *argv[])
- 51: {
- 52: glutInit(&argc,argv); //prepare glut
- 53: glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); //set the display m
- 54: glutInitWindowSize (500, 500); //the size of the program windo
- 55: glutInitWindowPosition (100, 100); //initial position for the wind
- 56: glutCreateWindow ("points and lines"); //create window with a title
- 57:
- 58: glClearColor(255,255,255,0.0); //background color
- 59: glMatrixMode (GL_PROJECTION); //2d envyronment
- 60: gluOrtho2D (0.0, 200.0, 0.0, 150.0); //matrix dimensions
- 61:
- 62: glutDisplayFunc(display); //show thee actual program
- 63: glutMainLoop();
- 64:
- 65: return EXIT_SUCCESS; //exit the program
- 66: }
- 67:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement