title: OpenGL changing vertex position
body: <p>I am using a simple GLsurfaceview to draw a simple white square covering most of the screen.
  when OnTouchEvent() is triggered the square should expand and de-expand according to the point pressed on screen. This is done by changing the vertex positions accordingly. </p>
  
  <pre><code>public void onDrawFrame(GL10 gl) {
      // Set GL_MODELVIEW transformation mode
      gl.glMatrixMode(GL10.GL_MODELVIEW);
      gl.glLoadIdentity();   // reset the matrix to its default state
      // When using GL_MODELVIEW, you must set the camera view
      GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
      square.draw(gl, x);
  }
  </code></pre>
  
  <p>The Square.draw() method:</p>
  
  <pre><code> public void draw(GL10 gl,float x) {
      Log.d("touch", "Square.draw() called");
      vertexBuffer.put(0,-(x/480)*2);
      vertexBuffer.put(6,-(x/480)*2);
  
      //Set the face rotation
      gl.glFrontFace(GL10.GL_CW);
  
      //Point to our vertex buffer
      gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
  
      //Enable vertex buffer
      gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
  
      //Draw the vertices as triangle strip
      gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
  
      //Disable the client state before leaving
      gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
  }
  </code></pre>
  
  <p>The GlsurfaceView containing the onTouchEvent:</p>
  
  <pre><code>public boolean onTouchEvent(MotionEvent e) {
      float x = e.getX();
      mRenderer.x = x;
  
      requestRender();
      return true;
  }
  </code></pre>
  
  <p>My initial thought was each time the screen is pressed the onTouchEvent() is triggered. I then pass the x coordinate to the renderer and from there to the draw method to change the vertexBuffer. This doesnt seem to work for two reasons:
  1. once i've covered the whole screen theres no going back no matter where i press.
  2. the point i press does not translate well. 
  I have tried using glTranslatef but might have done it wrong.</p>
  
  <p>I would like to stick to this method of changing the vertex positions rather than using glTranslatef.</p>