Note that there are some explanatory texts on larger screens.

plurals
  1. POGLSurfaceView continuously renders despite changing render mode
    text
    copied!<p>I'm trying to create a GLSurfaceView that displays a map of a game area. When the player moves, the game activity calls highlightSpot, which in turn should trigger a render request. The only time I want to re-draw the view is when the player moves.</p> <p>However, with my current implementation, despite calling <code>setRenderMode(RENDERMODE_WHEN_DIRTY)</code> on my GLSurfaceView, its render mode still seems to be continuous. To check, I threw a single println statement in my onDrawFrame method, and when I run my application, the output quickly fills up my logcat without the player moving even once-- it's clearly not behaving as I intended. Is there something else I need to do in order to make the view render only when asked?</p> <p>(The bulk of this code is derived from the tutorials at <a href="http://insanitydesign.com/wp/projects/nehe-android-ports/" rel="noreferrer">http://insanitydesign.com/wp/projects/nehe-android-ports/</a>. I omitted my onDrawFrame, OnSurfaceChanged, and onSurfaceCreated methods for the sake of conciseness, as I am not changing the render mode or requesting a render anywhere in those methods. If someone thinks it might be relevant, I can post those too.)</p> <pre><code>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 some variables here */ ... this.requestRender(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload