Screen Resolution change problem?

Hi,

I am running StandardGame and fengGUI using LWJGL on windows



when I try to change the screen resolution this way:




                OpenGL instance = OpenGL.getInstance(); // OpenGL is the StandardGame
                instance.getSettings().setWidth(width);
                instance.getSettings().setHeight(height);
                instance.getSettings().setFrequency(freq);
                instance.getSettings().setDepth(depth);

                instance.reinitVideo();



I get this exception


SEVERE: Cannot recreate window
org.lwjgl.LWJGLException: Could not make context current
        at org.lwjgl.opengl.WindowsContextImplementation.nMakeCurrent(Native Method)
        at org.lwjgl.opengl.WindowsContextImplementation.makeCurrent(WindowsContextImplementation.java:90)
        at org.lwjgl.opengl.Context.makeCurrent(Context.java:182)
        at org.lwjgl.opengl.Display.makeCurrent(Display.java:713)
        at org.lwjgl.opengl.Display.makeCurrentAndSetSwapInterval(Display.java:865)
        at org.lwjgl.opengl.Display.setDisplayMode(Display.java:252)
        at com.jme.system.lwjgl.LWJGLDisplaySystem.reinitDisplay(LWJGLDisplaySystem.java:485)
        at com.jme.system.lwjgl.LWJGLDisplaySystem.recreateWindow(LWJGLDisplaySystem.java:261)
        at com.jmex.game.StandardGame$1.call(StandardGame.java:418)
        at com.jme.util.GameTask.invoke(GameTask.java:140)
        at com.jme.util.GameTaskQueue.execute(GameTaskQueue.java:111)
        at com.jmex.game.StandardGame.update(StandardGame.java:378)
        at com.jmex.game.StandardGame.run(StandardGame.java:250)
        at java.lang.Thread.run(Thread.java:619)
Jan 7, 2010 4:13:08 AM com.jmex.game.DefaultUncaughtExceptionHandler uncaughtException
SEVERE: Main game loop broken by uncaught exception
java.lang.Error: Cannot recreate window: Could not make context current
        at com.jme.system.lwjgl.LWJGLDisplaySystem.reinitDisplay(LWJGLDisplaySystem.java:490)
        at com.jme.system.lwjgl.LWJGLDisplaySystem.recreateWindow(LWJGLDisplaySystem.java:261)
        at com.jmex.game.StandardGame$1.call(StandardGame.java:418)
        at com.jme.util.GameTask.invoke(GameTask.java:140)
        at com.jme.util.GameTaskQueue.execute(GameTaskQueue.java:111)
        at com.jmex.game.StandardGame.update(StandardGame.java:378)
        at com.jmex.game.StandardGame.run(StandardGame.java:250)
        at java.lang.Thread.run(Thread.java:619)
Java Result: -1073741819
BUILD SUCCESSFUL (total time: 29 seconds)



does anyone have a solution for this?  :?
thanks!

Hello,



usually, "Could not make context current" errors means that you are not running this code in the opengl thread.



There is information about forcing code to be run in the GL thread…



Good luck

well yeah I am aware of code injection

if you take a look inside the reinitVideo() in StandardGame you will see this



   public void reinitVideo() {
      GameTaskQueueManager.getManager().update(new Callable<Object>() {
         public Object call() throws Exception {
            displayMins();

            display.recreateWindow(settings.getWidth(), settings
                  .getHeight(), settings.getDepth(), settings
                  .getFrequency(), settings.isFullscreen());
            camera = display.getRenderer().createCamera(display.getWidth(),
                  display.getHeight());
            display.getRenderer().setBackgroundColor(backgroundColor);
            if ((settings.isMusic()) || (settings.isSFX())) {
               initSound();
            }
            return null;
         }
      });
   }



which means that this operation will occur inside the GLthread ...