Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i want to change the rendermode from RENDERMODE_WHEN_DIRTY to RENDERMODE_CONTINUOUSLY when i touch the screen.

WHAT i Need : Initially the object should be stationary. after touching the screen, it should move automatically. The motion of my object is a projectile motion ans it is working fine.

what i get : Force close and a NULL pointer exception.

My code :

public class BallThrowGLSurfaceView extends GLSurfaceView{

MyRender _renderObj;
Context context;
GLSurfaceView glView;

public BallThrowGLSurfaceView(Context context) {
    // TODO Auto-generated constructor stub
    _renderObj = new MyRender(context);
    glView = new GLSurfaceView(context.getApplicationContext());

public boolean onTouchEvent(MotionEvent event) {
    // TODO Auto-generated method stub
    if (event != null)
        if (event.getAction() == MotionEvent.ACTION_DOWN)
            if (_renderObj != null)
            {   Log.i("renderObj", _renderObj + "lll");
                // Ensure we call switchMode() on the OpenGL thread.
                // queueEvent() is a method of GLSurfaceView that will do this for us.
                queueEvent(new Runnable()
                    public void run()
                return true;
    return super.onTouchEvent(event);   


PS : i know that i am making some silly mistakes in this, but cannot figure out what it really is.

share|improve this question

closed as not a real question by Byte56, Laurent Couvidou, doppelgreener, Trevor Powell, Josh Petrie Oct 19 '12 at 17:34

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Could you add the NullPointerException.printStackTrace() to the question please? – Daniel Carlsson Sep 22 '12 at 14:34
@DanielCarlsson it is giving at this line. glView.setRenderMode(RENDERMODE_CONTINUOUSLY); – Sid Sep 23 '12 at 8:52
up vote 2 down vote accepted

Override a method, setRendermode in ballThrowSurfaceview class and call that overridden method in your touchevent class.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.