title: OpenGL drawing squares in a for loop
body: <p>I am trying to draw what is in the picture. So I can draw the random colored square but I am having trouble getting the for loop to draw squares in the patter like the image. <img src="https://i.stack.imgur.com/gXx9e.jpg" alt="enter image description here"></p>
  
  <p>Code:</p>
  
  <pre><code>for (int i =0; i &lt; image.width; i = i+5) {
      for (int j = 0; j &lt; image.height; j = j+5) {
  
          //will this for loop give me what's in the image?
          //want to incorporate the code below in here. Modifications?
          glPushMatrix();
          glTranslatef(i, j, 0);
          glColor3ub( rand()%255, rand()%255, rand()%255 );
          glBegin(GL_QUADS);
          glVertex2i(0,0);
          glVertex2i(1,0);
          glVertex2i(1,1);
          glVertex2i(0,1);
          glEnd();
          glPopMatrix();
      }
  }
  </code></pre>