title: OpenGL draw a star
body: <p>I am working on a 2D star. I was able to create 5 triangles for the points, and then the polygon for the middle, but when I ran the program, the polygon cut out a portion that was not colored. I tried to cover the non covered portion with a triangle and that also did not work.</p>
  
  <p>What is wrong with the code?  Or what I can add to ensure that none of my shapes have missing coloring?</p>
  
  <p>Here is my code: </p>
  
  <pre><code>void draw() {
  
  
      glBegin(GL_TRIANGLES);
  
      glColor3f(1, 0, 0);
      glVertex3f(-0.60, 0.77, 0);
  
      glColor3f(0, 1, 0);
      glVertex3f(-0.42, 0.77, 0);
  
      glColor3f(0, 0, 1);
      glVertex3f(-0.58, 0.68, 0);
  
      //second triangle top triangle
  
      glColor3f(1, 0, 0);
      glVertex3f(-0.64, 1, 0);
  
      glColor3f(0, 1, 0);
      glVertex3f(-0.68, 0.77, 0);
  
      glColor3f(0, 0, 1);
      glVertex3f(-0.60, 0.77, 0);
  
      //3rd Triangle
      glColor3f(1, 0, 0);
      glVertex3f(-0.68, 0.77, 0);
  
      glColor3f(0, 1, 0);
      glVertex3f(-0.7, 0.68, 0);
  
      glColor3f(0, 0, 1);
      glVertex3f(-0.86, 0.77, 0);
  
      //4th Triangle
      glColor3f(1, 0, 0);
      glVertex3f(-0.64, 0.63, 0);
  
      glColor3f(0, 1, 0);
      glVertex3f(-0.7, 0.68, 0);
  
      glColor3f(0, 0, 1);
      glVertex3f(-0.82, 0.43, 0);
  
      //5th Triangle
      glColor3f(1, 0, 0);
      glVertex3f(-0.64, 0.63, 0);
  
      glColor3f(0, 1, 0);
      glVertex3f(-0.58, 0.68, 0);
  
      glColor3f(0, 0, 1);
      glVertex3f(-0.51, 0.43, 0);
  
      glEnd();
  
      glBegin(GL_POLYGON);//code for the Polygon within the stars
      glColor3f(1, 0, 0);//sets color of Polygon
  
      glVertex3f(-0.68, 0.77, 0); //set the 5 vetices of polygon
  
      glColor3f(1, 0, 0);
      glVertex3f(-0.60, 0.77, 0);
  
      glColor3f(1, 0,0 );
      glVertex3f(-0.7, 0.68, 0);
  
      glColor3f(1, 0, 0);
      glVertex3f(-0.64, 0.63, 0);
  
      glColor3f(1, 0, 0);
      glVertex3f(-0.58, 0.68, 0);
  
  
  
  
      glEnd();
  
      //code for pentagaon
      glBegin(GL_POLYGON);
      glColor3f(1, 0, 0);//sets color of Polygon
      glVertex3f(0.45, 0.82, 0); //set the 5 vetices of polygon
  
      glColor3f(0, 1, 0);
      glVertex3f(0.8, 0.6, 0);
  
      glColor3f(0, 1, 0);
      glVertex3f(0.2, 0.6, 0);
  
      glColor3f(1, 0, 0);
      glVertex3f(0.2, 0.3, 0);
  
      glColor3f(1, 0, 0);
      glVertex3f(0.7, 0.3, 0);
  
  
      glEnd();
  }
  </code></pre>