title: Android pinch/zoom and glfrustum
body: <p>I draw several 2D shapes using <a href="http://en.wikipedia.org/wiki/OpenGL" rel="noreferrer">OpenGL</a> and now I want to add the pinch/zoom. My view is perspective (top view). I assumed that it's 3D with z axis = 0.</p>
  
  <p>Now, how should I change glfrustum and add on a touch method in my activity so that I could be able to pinch/zoom?</p>
  
  <pre><code>gl.glFrustumf(-ratio, ratio, -1, 1, 1, 25);
  </code></pre>
  
  <p>I think it should be something like</p>
  
  <pre><code>gl.glFrustumf(-ratio, ratio, -1, 1, 1*zoom, 25*zoom);
  </code></pre>
  
  <p>but how should the touch method be written to change this zoom parameter for doing two finger zoom?</p>
  
  <p>the problem is rendrer right now , I add zoom method at the end , but in zoom method it gives me error with gl.glfrustum while on onsurfacechanged it does not give me error with the same thing ! how could I fix that ?</p>
  
  <pre><code>public class GLrenderer implements Renderer {
      public GLqueue tri;
      public GLrenderer() {
          tri = new GLqueue();
  
  
      }
  
  
      public void onSurfaceCreated(GL10 gl, EGLConfig eglConfig) {
          // TODO Auto-generated method stub
          gl.glDisable(GL10.GL_DITHER);
          gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
          gl.glClearColor(.0f, .0f, .0f, 0f);
          gl.glClearDepthf(1f);
      }
  
  
      public void onDrawFrame(GL10 gl) {
          // TODO Auto-generated method stub
          gl.glDisable(GL10.GL_DITHER);
          gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_COLOR_BUFFER_BIT);
  
          gl.glMatrixMode(GL10.GL_MODELVIEW);
          gl.glLoadIdentity();
          GLU.gluLookAt(gl, 0, 0, -5, 0, 0, 0, 0, 2, 0);
  
          //gl.glRotatef(1, 1, 0, 0);
      //  gl.glRotatef(10, 0, 0, 1);
          tri.draw(gl);
  
      }
  
      public void onSurfaceChanged(GL10 gl, int width, int height ) {
          // TODO Auto-generated method stub
          gl.glViewport(0, 0, width, height);
          float ratio = (float) width / height;
          gl.glMatrixMode(GL10.GL_PROJECTION);
          gl.glLoadIdentity();
  
          gl.glFrustumf(-ratio, ratio, -1, 1, 1, 25);
      }
  
      public static void zoom(float d2) {
          // TODO Auto-generated method stub
            int zoom = (int) (zoom*d2);
  
                  gl.glFrustumf(-ratio, ratio, -1, 1, 1*zoom, 25*zoom);
  
      }
  
      }
  </code></pre>