Using either a Headless game or a Visible one

Well I'm currently working a bith more on the Gameserver for my game.

Now I thought that it would be pretty helpfull if I have a optional Rendering, so that i can see what the Server sees. After looking a  bit at  Standartgame, I came up with this (I extend FixedLogicrateGame) cause it kinda simplifies the serverside logic. While in debug = true everything works as expected, debug = false throws this one



initSystem
06.04.2009 15:43:54 com.jme.input.joystick.DummyJoystickInput <init>
INFO: Joystick support is disabled
06.04.2009 15:43:54 com.jme.input.lwjgl.LWJGLMouseInput <init>
WARNUNG: Problem during creation of Mouse.
java.lang.IllegalStateException: Display must be created.
   at org.lwjgl.input.Mouse.create(Mouse.java:266)
   at com.jme.input.lwjgl.LWJGLMouseInput.<init>(LWJGLMouseInput.java:100)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at com.jme.input.MouseInput.get(MouseInput.java:74)
   at com.jme.input.InputSystem.update(InputSystem.java:67)
   at com.jme.app.FixedLogicrateGame.start(FixedLogicrateGame.java:134)
   at Starter$1.run(Starter.java:52)
   at java.lang.Thread.run(Unknown Source)
06.04.2009 15:43:54 class GameObjects.Universe start()
SCHWERWIEGEND: Exception in game loop
java.lang.IllegalStateException: Cannot determine focused state of uncreated window
   at org.lwjgl.opengl.Display.isActive(Display.java:569)
   at com.jme.input.lwjgl.LWJGLMouseInput.update(LWJGLMouseInput.java:187)
   at com.jme.input.InputSystem.update(InputSystem.java:67)
   at com.jme.app.FixedLogicrateGame.start(FixedLogicrateGame.java:134)
   at Starter$1.run(Starter.java:52)
   at java.lang.Thread.run(Unknown Source)
06.04.2009 15:43:54 com.jme.app.FixedLogicrateGame start
INFO: Application ending.




   @Override
   protected void initSystem() {
      Console.println("initSystem");
      settings.setHeight(480);
      settings.setWidth(640);
      if (debug){
         display = DisplaySystem.getDisplaySystem("LWJGL");
      }
      else{
         display = DisplaySystem.getDisplaySystem("dummy");
      }
      display.setMinDepthBits(24);
      display.setMinStencilBits(2);
      display.setMinAlphaBits(8);
      display.setMinSamples(2);
      display.setVSyncEnabled(false);
      display.setTitle("GameServer");
      timer = Timer.getTimer();
      if (debug){
         display.createWindow(settings.getWidth(),settings.getHeight(), 32, 120,false);
      }
      else{
         display.createHeadlessWindow(settings.getWidth(),settings.getHeight(),settings.getDepth() );
      }
      cam = display.getRenderer().createCamera(display.getWidth(),display.getHeight());
      if (debug){
         cameraPerspective();
      }
      display.getRenderer().setBackgroundColor(ColorRGBA.black.clone());
      Vector3f loc = new Vector3f(0.0f, 0.0f, 25.0f);
      Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
      Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
      Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
      if (debug){
         cam.setFrame(loc, left, up, dir);
         cam.update();
         display.getRenderer().setCamera(cam);
      }
   }



I already tried to do the camera stuff for the dummy as well, but that just thorws nullpointerexceptions.

Can anyone maybee give me a hint why this does not work?

It seems FixedLogicrateGame does not properly support headless rendering. You may need to edit it to remove references to InputHandler and other rendering stuff so it works.

As Momoko_Fan already said just comment the line 'InputSystem.update();' out.

MouseInput and KeyInput do not support a Dummy input systm yet.

The funny thing is, JoystikInput does support it.



You could implement the missing DummyMouseInput and DummyKeyboardInput classes, and use this new classes by setting dummy providers before starting the game.



DummyMouseInput.setProvider(MouseInput.INPUT_DUMMY);



dumdidummdumm…

Hm I think i will take a look into creating the dummy classes, and if i get them to work, maybee someone can integrate them into the framework then, so everyone will be helped a bit :slight_smile:

Sure, just post a patch in the contribution depot if it works out.



Maybe there is also a good reason why they are missing, but i can't think of one right now.

Done, and seems to work as expected, now back to the Server codeing ^^



http://www.jmonkeyengine.com/jmeforum/index.php?topic=10853.0