android - GLSurfaceView continuously renders despite changing render mode -


i'm trying create glsurfaceview displays map of game area. when player moves, game activity calls highlightspot, in turn should trigger render request. time want re-draw view when player moves.

however, current implementation, despite calling setrendermode(rendermode_when_dirty) on glsurfaceview, render mode still seems continuous. check, threw single println statement in ondrawframe method, , when run application, output fills logcat without player moving once-- it's not behaving intended. there else need in order make view render when asked?

(the bulk of code derived tutorials @ http://insanitydesign.com/wp/projects/nehe-android-ports/. omitted ondrawframe, onsurfacechanged, , onsurfacecreated methods sake of conciseness, not changing render mode or requesting render anywhere in methods. if thinks might relevant, can post too.)

public class surfaceviewclass extends glsurfaceview implements renderer {     public surfaceviewclass(context context) {         super(context);          ...          this.setrenderer(this);         this.setrendermode(rendermode_when_dirty);     }      public void highlightspot(int x, int y) {         /* change variables here */         ...          this.requestrender();     } } 

ok, think got sorted out. place set render mode seems class contains glsurfaceview object, not in glsurfaceview constructor. (something think overlooked in the android documentation glsurfaceview) can't set render mode of glsurfaceview before set renderer. perhaps why attempting set render mode in constructor not work.

this seems force render when want to, wanted:

public class game extends activity { private glsurfaceview glsurface; private surfaceviewclass svc;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);     glsurface = (glsurfaceview) findviewbyid(r.id.surfaceview01);      svc = new surfaceviewclass(this);     glsurface.setrenderer(svc);     glsurface.setrendermode(glsurfaceview.rendermode_when_dirty); }  public void moveplayer() {     svc.highlightspot(location[player], 0);     glsurface.requestrender(); } } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -