{"id":6921,"date":"2014-05-11T17:45:28","date_gmt":"2014-05-11T17:45:28","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/11\/nullpointerexception-on-render-collection-of-common-programming-errors\/"},"modified":"2014-05-11T17:45:28","modified_gmt":"2014-05-11T17:45:28","slug":"nullpointerexception-on-render-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/11\/nullpointerexception-on-render-collection-of-common-programming-errors\/","title":{"rendered":"NullPointerException on Render-Collection of common programming errors"},"content":{"rendered":"<p>when I try to debug this, I got a nullpointerexception. I just don&#8217;t get it, something must not been initialized correctly but I can&#8217;t see what&#8230; Thanks!<\/p>\n<pre><code>@Override\npublic void create()\n{       \n    Texture.setEnforcePotImages(false);\n    camera = new OrthographicCamera(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);\n    camera.setToOrtho(true,VIRTUAL_WIDTH,VIRTUAL_HEIGHT);\n    batch = new SpriteBatch();\n\n    labyrinthe = new Labyrinthe(2, VIRTUAL_WIDTH);\n    labyrinthe.generer();\n    joueur = labyrinthe.getJoueur();\n}\n\n@Override\npublic void dispose()\n{\n    batch.dispose();\n}\n\n@Override\npublic void render()\n{               \n    camera.position.set(joueur.getX(), joueur.getY(), 0);\n    camera.update();\n    camera.apply(Gdx.gl10);\n\n    Gdx.gl.glViewport((int) viewport.x, (int) viewport.y, (int) viewport.width, (int) viewport.height);\n    Gdx.gl.glClearColor(1, 1, 1, 1);\n    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);\n\n    batch.setProjectionMatrix(camera.combined);\n    batch.begin();\n    dessinerLabyrinthe();\n    dessinerJoueur();\n    batch.end(); \/\/ Exception on this line\n}\n<\/code><\/pre>\n<p>Edit : here is the exception :<\/p>\n<pre><code>08-24 09:22:02.413: W\/dalvikvm(224): threadid=21: thread exiting with uncaught exception (group=0x4001b188)\n08-24 09:22:02.413: E\/AndroidRuntime(224): Uncaught handler: thread GLThread exiting due to uncaught exception\n08-24 09:22:02.480: E\/AndroidRuntime(224): java.lang.NullPointerException\n08-24 09:22:02.480: E\/AndroidRuntime(224):  at com.badlogic.gdx.graphics.g2d.SpriteBatch.renderMesh(SpriteBatch.java:1042)\n08-24 09:22:02.480: E\/AndroidRuntime(224):  at com.badlogic.gdx.graphics.g2d.SpriteBatch.end(SpriteBatch.java:269)\n08-24 09:22:02.480: E\/AndroidRuntime(224):  at com.me.crazymazes.CrazyMazes.render(CrazyMazes.java:60)\n08-24 09:22:02.480: E\/AndroidRuntime(224):  at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:452)\n08-24 09:22:02.480: E\/AndroidRuntime(224):  at com.badlogic.gdx.backends.android.surfaceview.GLSurfaceViewCupcake$GLThread.guardedRun(GLSurfaceViewCupcake.java:713)\n08-24 09:22:02.480: E\/AndroidRuntime(224):  at com.badlogic.gdx.backends.android.surfaceview.GLSurfaceViewCupcake$GLThread.run(GLSurfaceViewCupcake.java:646)\n<\/code><\/pre>\n<p>Edit2: Never mind I forgot to call the function that generates the textures&#8230;. Thanks anyway<\/p>\n","protected":false},"excerpt":{"rendered":"<p>when I try to debug this, I got a nullpointerexception. I just don&#8217;t get it, something must not been initialized correctly but I can&#8217;t see what&#8230; Thanks! @Override public void create() { Texture.setEnforcePotImages(false); camera = new OrthographicCamera(VIRTUAL_WIDTH, VIRTUAL_HEIGHT); camera.setToOrtho(true,VIRTUAL_WIDTH,VIRTUAL_HEIGHT); batch = new SpriteBatch(); labyrinthe = new Labyrinthe(2, VIRTUAL_WIDTH); labyrinthe.generer(); joueur = labyrinthe.getJoueur(); } @Override public [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6921","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6921"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6921\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}