java - GLThread throws NullPointerException -


im trying set initial game state in glsurefaceview.renderer class, , create sprite object in initialgamestate(context) , calling methods in render() exception thrown in glthread.

public class myrenderer implements glsurfaceview.renderer  {     private context m_context;     private gamestatemanager m_game;      public myrenderer(context context)      {         m_context = context;         m_game = gamestatemanager.getinstance();         m_game.setgamestate(new ingame(m_context));     }      @override     public void ondrawframe(gl10 gl)      {         gles20.glclear(gles20.gl_color_buffer_bit);          m_game.getcurrentstate().render();     }      @override     public void onsurfacechanged(gl10 gl, int width, int height)      {         gles20.glviewport(0, 0, width, height);     }      @override     public void onsurfacecreated(gl10 gl, eglconfig config)      {         gles20.glclearcolor(0.63671875f, 0.76953125f, 0.22265625f, 1.0f);         shadermanager.getinstance().createdefaultshaders(m_context);       } }   public class ingame extends gamestate {     private sprite m_sprite;     private boolean m_isinitialized = false;      public ingame(context context)      {         super(context);          m_sprite = new sprite(m_context);     }      @override     public void render()      {         if (!m_isinitialized)         {              m_sprite.create("clover.png");             m_isinitialized = true;         }         else         {             m_sprite.begin();             m_sprite.draw();             m_sprite.end();         }        } } 

everything works fine when call m_game.setgamestate(new ingame(context)) in onsurfacecreated(). can fixed?

thread [<9> glthread 10] (suspended (exception nullpointerexception))        <vm not provide monitor information>        glsurfaceview$glthread.run() line: 1122  


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -