Android : Switching between Activities that render OpenGL ES 2.0 : Perspective gets corrupted -
i have app has 2 main activities both render opengl es 2.0 surface/renderer/context
when go 1 activity next, renders fine on new activity, onpause called on first activity pauses surface.
when homecoming first activity calling finish on sec activity, rendered view perspective goes weird, its been zoomed out.
the onsurfacecreated called, , onsurfacedchanged called twice on first activity (when returning).
@override public void onsurfacecreated(gl10 unused, eglconfig config) { // set background frame color gles20.glclearcolor(0.0f, 0.0f, 0.0f, 1.0f); gles20.glenable(gles20.gl_depth_test); gles20.gldepthfunc(gles20.gl_lequal); gles20.gldepthmask(true); mcamera = new camera(camera.player_ipd, camera.player_eye_height, camera.camera_fov, 1); mcamera.mposz = 10; mipd = mcamera.getipd(); } @override public void onsurfacechanged(gl10 unused, int width, int height) { screenwidth = width; screenheight = height; mhalfwidth = screenwidth / 2; mheight = screenheight; mratio = (float) mhalfwidth / height; mcamera.setfov(mcamera.getfov(), mratio); framechecktime = system.currenttimemillis() + 1000; float ratio = (float) width / height; matrix.frustumm(mprojectionmatrix, 0, -ratio, ratio, -1, 1, 1.0f, 10); matrix.setlookatm(mviewmatrix, 0, 0, 0, -1.0000001f, 0.0f, 0f, 0f, 0f, 1.0f, 0.0f); } @override protected void onpause() { super.onpause(); mglview.onpause(); } @override protected void onresume() { super.onresume(); mglview.onresume(); }
before
after
android opengl-es-2.0 glsurfaceview perspectivecamera
No comments:
Post a Comment