1
votes

I am showing 2D Image on GLSurfaceView and Want to rotate it with specific degree (ie. 180 ,75,360...)

I written following code in touch event.( Here GPUImageView extends GLSurfaceView ) and I am getting value in variable rotationDegree from my Rotate Gesture Detector class which process two finger rotation gestures. Below code rotate the GLSufaceview but content / iamge shown in GLSurfaceView remain same (not rotating inside it). android have examples but they are for 3D and not rotation with degree.

    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
        rotationDetector.onTouchEvent(event);
        /* Rotate View Here */
        GPUImageView.this.setRotation(rotationDegree);
        requestRender();
        return true;
    }

I have my custom rotation detector class which dispatches events related to two finger rotation

    private class RotateListener extends RotateGestureDetector.SimpleOnRotateGestureListener
    {
        @Override
        public boolean onRotate(RotateGestureDetector detector)
        {
            rotationDegree -= detector.getRotationDegreesDelta();
            return true;
        }
    }
1
Where is the code that actually sets rotationDegree? Within the code you have shown for this particular function it is constant.Andon M. Coleman
I added code how I modifify rotationDegree variable. rotationDegree is variable which is modified when two finger rotation is done which is detected by my custom RotationGestureDetecter Class.As I said rotation works fine but it does only rotate outer view internal content remain on same position.Kirtan

1 Answers

0
votes

you can also rotate the surface view via the ModelMatrix..

onDrawFrame()
{
Matrix.tramslateM(yourModelMatrix,offsetValue,translationInx,translationInY,translationInZ);
Matrix.rotateM(yourModelMatrix,offsetValue,andgle in degrees,inDirectionX,inDirectioY,inDirectionZ);
}