2

I try to use setRotation() on my GLSurfaceView, but the view seems not rotate around the pivot which is the center of the screen. the code like below:

class MyGLSurfaceView extends GLSurfaceView {
    private float mCurRotation = 0.0f;

    @Override
    public boolean onTouchEvent(MotionEvent e) {
        mCurRotation = mCurRotation + 10;
        setRotation(mCurRotation);
    }
}

Is there any body know the reason and teach me how to rotate my GLSurfaceView?

genpfault
  • 51,148
  • 11
  • 85
  • 139
leoncheng
  • 43
  • 5
  • Here is posted a good answer on how to make it using OpenGL: https://stackoverflow.com/questions/36703984/rotating-android-camera-preview-by-90-degrees-on-glsurfaceview-using-opengl-2-0 – Zuum Dj Nov 29 '17 at 12:44

1 Answers1

2

Contrary to your expectation, methods of View doesn't work well.

GLSurfaceView punches a hole to display underneath surface. Actually it has only transparent pixels.

If you want to rotate your image, you have to use OpenGL operations.

Dalinaum
  • 1,142
  • 13
  • 18