# android: How to apply pinch zoom and pan to 2D GLSurfaceView

I want to apply pinch zoom and panning effect on GLSurfaceView. It is Image editor, so It would not be 3D object. I tried to implement using these following links:
Want to apply pinch and zoom to GLSurfaceView(3d Object) http://www.learnopengles.com/android-lesson-one-getting-started/

These all are links for 3D object rendering. I can not use ImageView as I need to work out with OpenGL so, had to implement it on GLSurfaceView.

Suggest me or any reference links are there for such implementation. **I need it for 2D only.

I am able to do both now, but where I am getting problem is to set the pivot point while panning can any one help me to set the translation respective to pivot point?

Matrix.setIdentityM(mScaleMatrix, 0);
Matrix.scaleM(mScaleMatrix, 0, scaleX, scaleY, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mScaleMatrix, 0);
Matrix.setIdentityM(mTranslateMatrix, 0);
Matrix.translateM(mTranslateMatrix, 0, deltaX, deltaY, 0);
Matrix.multiplyMM(mProjectionMatrix, 0, mProjectionMatrix, 0,
mTranslateMatrix, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);

• Have you tried the standard Android way of implementing a gesture listener with a motiondetector on your activity? – MLProgrammer-CiM Oct 18 '13 at 9:55
• Yes I have implemented that but how to scale GLSurfaceView? do you have any reference link or code? – mayank_droid Oct 19 '13 at 5:23

You are most likely using an orthographic projection for your 2D view, so have a look at this thread for a discussion on how to achieve zooming using glOrtho().