surfaceview - Stop OnDrawFrame of Android GLSurfaceView -
i writing application in using glsurfaceview draw shapes on display.the issue want pause drawing or stop drawing , resume again.glsurfaceview setrenderer called oncein lifetime of application.ondrawframe overriden function of glsurfaceview class os cannot disable it.so should go stopping/pausing drawing , resume again.i trying draw follows:
mglsurfaceview = new glsurfaceview(mcontext); mrelativelayout.addview(mglsurfaceview,mrelativelayout.getlayoutparams()); mglsurfaceview.seteglcontextclientversion(2); mglsurfaceview.setrenderer(new lessonfiverenderer(mcontext));
and trying pause/stop follows:
mglsurfaceview.onpause(); mglsurfaceview.getholder().getsurface().release(); mglsurfaceview.setvisibility(view.invisible); mglsurfaceview.destroydrawingcache(); //mrelativelayout.destroydrawingcache(); mglsurfaceview.invalidate(); mglsurfaceview.clearanimation(); mglsurfaceview.postinvalidate(); mrelativelayout.removeview(mglsurfaceview); mrelativelayout.destroydrawingcache(); //mrelativelayout.removeallviewsinlayout(); mrelativelayout.invalidate();
but issue drawing keeps happening in background.how should go stop drawing.
glsurfaceview can draw continuously or on demand. alter mode setrendermode() method.
if pass rendermode_continuously
, draw method called scheme can so. (this "queue stuffing" approach settles match device refresh rate; see this article.) if pass rendermode_when_dirty
, render if phone call requestrender()
.
you can see illustration of in android breakout. when game won or lost, glsurfaceview switched render-when-dirty mode.
android surfaceview
No comments:
Post a Comment