title: Error with GL_TRIANGLE_STRIP and vertex array
body: <p>I have this method that prepares the coordinates in the posCoords array. It works properly about 30% of the time, then the other 70% the first few triangles are messed up in the grid.
  The entire grid is drawn using GL_TRIANGLE_STRIP.
  I'm pulling my hair out trying to figure out whats wrong. Any ideas?</p>
  
  <p><img src="https://i.stack.imgur.com/SVZDX.jpg" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/DtdeF.jpg" alt="enter image description here"></p>
  
  <pre><code>if(!ES2) {
      glEnableClientState(GL_VERTEX_ARRAY);
      glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  }
  
  int cols = floor(SCREEN_WIDTH/blockSize);
  int rows = floor(SCREEN_HEIGHT/blockSize);
  int cells = cols*rows;
  NSLog(@"Cells: %i", cells);
  coordCount =  /*Points per coordinate*/2 * /*Coordinates per cell*/ 2 * cells + /* additional coord per row */2*2*rows;
  
  NSLog(@"Coord count: %i", coordCount);
  
  if(texCoords) free(texCoords);
  if(posCoords) free(posCoords);
  if(dposCoords) free(dposCoords);
  
  texCoords = malloc(sizeof(GLfloat)*coordCount);
  posCoords = malloc(sizeof(GLfloat)*coordCount);
  dposCoords = malloc(sizeof(GLfloat)*coordCount);
  
  int index = 0;
  
  
  float lowY, hiY = 0;
  int x,y = 0;
  BOOL drawLeftToRight = YES;
  for(y=0;y&lt;SCREEN_HEIGHT;y+=blockSize) {
  
      lowY = y;
      hiY = y + blockSize;
  
      // Draw a single row
      for(x=0;x&lt;=SCREEN_WIDTH;x+=blockSize) {
          CGFloat px,py,px2,py2 = 0;
  
          // Top point of triangle
          if(drawLeftToRight) {
              px = x;
              py = lowY;
  
              // Bottom point of triangle
              px2 = x;
              py2 = hiY;
          }
          else {
              px = SCREEN_WIDTH-x;
              py = lowY;
  
              // Bottom point of triangle
              px2 = SCREEN_WIDTH-x;
              py2 = hiY;
          }
  
          // Top point of triangle
          posCoords[index] = px;
          posCoords[index+1] = py;
  
          // Bottom point of triangle
          posCoords[index+2] = px2;
          posCoords[index+3] = py2;
  
          texCoords[index] = px/SCREEN_WIDTH;
          texCoords[index+1] = py/SCREEN_HEIGHT;
          texCoords[index+2] = px2/SCREEN_WIDTH;
          texCoords[index+3] = py2/SCREEN_HEIGHT;
  
          index+=4;
      }
  
      drawLeftToRight = !drawLeftToRight;
  
  
  
  }
  </code></pre>