title: Rotate a simple polygon in OpenGL
body: <p>I follow the code tutorial from <a href="https://en.wikibooks.org/wiki/OpenGL_Programming/GLStart/Tut4" rel="nofollow noreferrer">the OpenGL programming book</a>, but it doesn't work. It is showing white rectangle at the top left of my window. Could you please tell me what could be wrong with it? </p>
  
  <pre><code>#include&lt;windows.h&gt;
  #include &lt;GL/glut.h&gt;
  float yRot=0.0;
  void Render()
  {
    //clear color and depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();//load identity matrix
  
    glTranslatef(0.0f,0.0f,-4.0f);//move forward 4 units
  
    //rotate along the y-axis
    glRotatef(yRot,0.0f,1.0f,0.0f);
  
    glColor3f(0.0f,0.0f,1.0f); //blue color
  
    glBegin(GL_POLYGON);//begin drawing of polygon
      glVertex3f(-0.5f,0.5f,0.0f);//first vertex
      glVertex3f(0.5f,0.5f,0.0f);//second vertex
      glVertex3f(1.0f,0.0f,0.0f);//third vertex
      glVertex3f(0.5f,-0.5f,0.0f);//fourth vertex
      glVertex3f(-0.5f,-0.5f,0.0f);//fifth vertex
      glVertex3f(-1.0f,0.0f,0.0f);//sixth vertex
    glEnd();//end drawing of polygon
  
    yRot+=0.1f;//increment the yRot variable
  }
  //method the reshape the entire figure.
  void reshape(int x, int h){
      glViewport(0,0,x,h);
  }
  void init()
  {
      glClearColor(0.0,0.0,0.2,0.8);
  }
  int main(int argc, char** argv)
  {
     glutCreateWindow("simple triangles");
     glutDisplayFunc(Render);
     glutReshapeFunc(reshape);
     init();
  
     glutMainLoop();
  }
  </code></pre>