Display.setVSyncEnabled(true); ERROR

When I use display.setVSyncEnabled(true); I suddenly get an error




03.03.2009 18:46:57 org.odejava.Odejava <clinit>
INFO: OdeJava natives version 0.3.1 loaded.
Exception in thread "main" java.lang.NullPointerException
   at org.lwjgl.opengl.GL11.glGetError(GL11.java:1284)
   at org.lwjgl.opengl.Util.checkGLError(Util.java:52)
   at org.lwjgl.opengl.WindowsContextImplementation.setSwapInterval(WindowsContextImplementation.java:103)
   at org.lwjgl.opengl.Context.setSwapInterval(Context.java:224)
   at org.lwjgl.opengl.Display.setSwapInterval(Display.java:929)
   at org.lwjgl.opengl.Display.setVSyncEnabled(Display.java:941)
   at com.jme.system.lwjgl.LWJGLDisplaySystem.setVSyncEnabled(LWJGLDisplaySystem.java:108)
   at game.bin.gamesys.EngineGameState.<init>(EngineGameState.java:86)
   at game.Main.main(Main.java:75)



Any suggestion?
DarkPhoenixX said:

When I use display.setVSyncEnabled(true); I suddenly get an error


03.03.2009 18:46:57 org.odejava.Odejava <clinit>
INFO: OdeJava natives version 0.3.1 loaded.
Exception in thread "main" java.lang.NullPointerException
   at org.lwjgl.opengl.GL11.glGetError(GL11.java:1284)
   at org.lwjgl.opengl.Util.checkGLError(Util.java:52)
   at org.lwjgl.opengl.WindowsContextImplementation.setSwapInterval(WindowsContextImplementation.java:103)
   at org.lwjgl.opengl.Context.setSwapInterval(Context.java:224)
   at org.lwjgl.opengl.Display.setSwapInterval(Display.java:929)
   at org.lwjgl.opengl.Display.setVSyncEnabled(Display.java:941)
   at com.jme.system.lwjgl.LWJGLDisplaySystem.setVSyncEnabled(LWJGLDisplaySystem.java:108)
   at game.bin.gamesys.EngineGameState.<init>(EngineGameState.java:86)
   at game.Main.main(Main.java:75)



Any suggestion?

Maybe you are not on the OpenGL thread when you call this method.

Stupid question





How does the OpenGL thread look like?

firstly: you have to invoke that method BEFORE you call standardGame.start():



secondly: read these, shouldn’t take long:

=list&s[]=calls]http://www.jmonkeyengine.com/wiki/doku.php?id=what_calls_must_be_made_from_the_opengl_thread&s[]=list&s[]=calls



=darkfrog]http://www.jmonkeyengine.com/wiki/doku.php?id=standardgame_gamestates_and_multithreading_a_new_way_of_thinking&s[]=darkfrog



especially around the part where theres an example with the

GameTaskQueueManager





or search the forums for the

GameTaskQueueManager

for a quick fix.



EDIT: you can find out when youre inside the OpenGL thread or not by calling

standardGame.inGLThread();

Thanks!

Works!