Advertisement
Guest User

stardrow

a guest
Apr 9th, 2020
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.37 KB | None | 0 0
  1. /*
  2. Shamsuddin Ahmed
  3. 161-15-1027
  4.  
  5. Draw Star using lines
  6. */
  7.  
  8.  
  9. #include<windows.h>
  10. #include <GL/glut.h>
  11.  
  12. void init(void)
  13. {
  14.     glClearColor(1.0, 1.0, 1.0, 0.0);   // Set display window colour to white
  15.  
  16.     glMatrixMode(GL_PROJECTION);        // Set projection parameters
  17.     gluOrtho2D(0.0, 400.0, 0.0, 400.0);
  18. }
  19.  
  20. void drawShapes(void)
  21. {
  22.     glClear(GL_COLOR_BUFFER_BIT);   // Clear display window
  23.  
  24.     //Set colour to black
  25.     glColor3f(0.0, 0.0, 0.0);
  26.     //Adjust the point size
  27.     glPointSize(5.0);
  28.  
  29.     //Set colour to red
  30.     glColor3f(1.0, 0.0, 0.0);
  31.  
  32.     // Draw an outlined triangle
  33.     glBegin(GL_LINES);
  34.  
  35.  
  36.         //Rectangle Using Line
  37.         glVertex2i(150, 150); //A
  38.         glVertex2i(250, 150); //B
  39.  
  40.         glVertex2i(250, 150);
  41.         glVertex2i(250,250); //C
  42.  
  43.  
  44.         glVertex2i(150, 250);
  45.         glVertex2i(150, 150);
  46.  
  47.         glVertex2i(250,250);
  48.         glVertex2i(150, 250); //D
  49.         //Rectangle End
  50.  
  51.         //Start First Triangle Using Line
  52.  
  53.         glVertex2i(250,250);      //C
  54.         glVertex2i(200, 350);    //E
  55.  
  56.         glVertex2i(200, 350);  //E
  57.         glVertex2i(150, 250); //D
  58.  
  59.         //End First Triangle Using Line
  60.  
  61.  
  62.  
  63.  
  64.         //Start 2nd Triangle Using Line
  65.  
  66.         glVertex2i(150, 150); //A
  67.         glVertex2i(200, 50); //G
  68.  
  69.         glVertex2i(200, 50); //G
  70.         glVertex2i(250, 150); //B
  71.  
  72.         //End 2nd Triangle Using Line
  73.  
  74.  
  75.         //Start 3rd Triangle Using Line
  76.  
  77.         glVertex2i(250, 150); //B
  78.         glVertex2i(350, 200); //F
  79.  
  80.         glVertex2i(250,250); //C
  81.         glVertex2i(350, 200); //F
  82.  
  83.         //End 3rd Triangle Using Line
  84.  
  85.  
  86.         //Start 4th Triangle Using Line
  87.  
  88.         glVertex2i(150, 250); //D
  89.         glVertex2i(50, 200); //H
  90.  
  91.         glVertex2i(50, 200); //H
  92.         glVertex2i(150, 150); //A
  93.  
  94.         //End 4th Triangle Using Line
  95.  
  96.     glEnd();
  97.  
  98.     glFlush();  // Process all OpenGL routines
  99. }
  100.  
  101. int main(int argc, char* argv[])
  102. {
  103.     glutInit(&argc, argv);                      // Initalise GLUT
  104.     glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);  // Set display mode
  105.  
  106.     glutInitWindowPosition(50, 100);                // Set window position
  107.     glutInitWindowSize(400, 300);                   // Set window size
  108.     glutCreateWindow("An Example OpenGL Program");  // Create display window
  109.  
  110.     init();                         // Execute initialisation procedure
  111.     glutDisplayFunc(drawShapes);        // Send graphics to display window
  112.     glutMainLoop();                 // Display everything and wait
  113.  
  114.     return 0;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement