title: 2D Drawing In OpenGL ES 2.0 (iOS)
body: <p>I'm learning how to use OpenGL ES 2.0 on iOS. Right now I want to just do some basic 2D animation (e.g. move a rectangle around the screen and change its size). I've started out with the project template for OpenGL ES provided by Apple in Xcode. My drawing code looks like this:</p>
  
  <pre><code>static GLfloat squareVertices[] = {
      -0.5f, -0.33f,
      0.5f, -0.33f,
      -0.5f,  0.33f,
      0.5f,  0.33f
   };
  
  // Update attribute values.
  glVertexAttribPointer(VERTEX_ATTR, 2, GL_FLOAT, 0, 0, squareVertices);
  glEnableVertexAttribArray(VERTEX_ATTR);
  
  glVertexAttribPointer(COLOR_ATTR, 4, GL_UNSIGNED_BYTE, 1, 0, squareColors);
  glEnableVertexAttribArray(COLOR_ATTR);
  
  glDrawArrays(GL_TRIANGLE_STRIP, 0, 5);
  </code></pre>
  
  <p>Now this will draw a <a href="http://imgur.com/uMKG1.png" rel="nofollow">nice rectangle</a> in the middle of the screen. But if I start to change the rectangle by adding the following code, it starts to <a href="http://imgur.com/2kYi8.png" rel="nofollow">look funky</a>:</p>
  
  <pre><code>squareVertices[5] -= .001;
  squareVertices[7] -= .001;
  </code></pre>
  
  <p>It is as if part of the rectangle is attached to the center of the screen. I am completely new to OpenGL ES so I'm sure my problem is obvious. I also assume this has something to do with OpenGL ES being a 3D graphics library and I'm trying to treat it as a 2D space. So my question is: What is the best way to draw and animate 2D objects in OpenGL ES 2.0? I've seen some stuff online for OpenGL ES 1.1, but that is not much help to me. Are their special techniques for 2D drawing in OpenGL ES 2.0, or is there some sort of 2D drawing mode?</p>
  
  <p>Any guidance would be greatly appreciated.</p>