JMEDesktop invisible?

im upgrading my app from jme 1.0 and old physics to jme from cvs and new physics. I immediatly run into a problem with JMEDesktop.

its there and i can click on it but i cant see it. It worked fine before upgrade. any ideas what might have changed to cause this?

I have a simple example of invisible desktop I can post if noone has easy answer. thanks in advance dudes 8)

the JMEDesktop tests work fine, its prob a simple mistake im making but I sure cant find it.

here is an example of problem, it should be a window with a button to exit,

but I get an invisible button/desktop. I can click on it but I cant see it.

import java.util.logging.Level;



import com.foosball.menu.MainMenuState;

import com.jme.app.GameState;

import com.jme.app.GameStateManager;

import com.jme.input.InputSystem;

import com.jme.input.KeyInput;

import com.jme.input.MouseInput;

import com.jme.input.joystick.JoystickInput;

import com.jme.renderer.ColorRGBA;

import com.jme.system.DisplaySystem;

import com.jme.system.JmeException;

import com.jme.util.LoggingSystem;

import com.jme.util.Timer;



public class MainGame {

   

   

    private static boolean finished;

    protected DisplaySystem display;

   private Timer timer;

   private int width, height, depth, freq;

   private boolean fullscreen;

   private float tpf;

   

   public static void main(String[] args) {

      

      MainGame app = new MainGame();

      

      app.start();

      

   }

   protected void assertDisplayCreated() throws JmeException {

        if (display == null) {

            LoggingSystem.getLogger().log(Level.SEVERE, "Display system is null.");



            throw new JmeException("Window must be created during" + " initialization.");

        }

        if (!display.isCreated()) {

            LoggingSystem.getLogger().log(Level.SEVERE, "Display system not initialized.");



            throw new JmeException("Window must be created during" + " initialization.");

        }

    }



   public final void start() {

        LoggingSystem.getLogger().log(Level.INFO, "Application started.");

        try {

           

            if (!finished) {

                initSystem();



                assertDisplayCreated();



                initGame();



                // main loop

                while (!finished && !display.isClosing()) {

                   

                    InputSystem.update();



                    update(-1.0f);



                    render(-1.0f);



                    display.getRenderer().displayBackBuffer();



                    Thread.yield();

                }

               

            }

        } catch (Throwable t) {

            t.printStackTrace();

        }

        cleanup();

        LoggingSystem.getLogger().log(Level.INFO, "Application ending.");



        if (display != null)

            display.reset();

        quit();

    }

   protected void quit() {

        if (display != null)

            display.close();

        System.exit(0);

    }

   

   protected void initSystem() {

      

      width = 800;

      height = 600;

      depth = 16;

      freq = 60;

      fullscreen = false;

      

      try {

         

         display = DisplaySystem.getDisplaySystem();

           display.createWindow(width, height, depth, freq, fullscreen);

          

      } catch (JmeException e) {

         e.printStackTrace();

         System.exit(1);

      }



      

      display.getRenderer().setBackgroundColor(ColorRGBA.black);      

      display.getRenderer().enableStatistics(true);

      timer = Timer.getTimer();

      

      

   }



   protected void initGame() {

      

      GameStateManager.create();

      GameState menu = new MainMenuState("main menu");

      menu.setActive(true);

      GameStateManager.getInstance().attachChild(menu);

      

   }

   

   protected void cleanup() {

      

      LoggingSystem.getLogger().log(Level.ALL, "Cleaning up resources.");

      GameStateManager.getInstance().cleanup();   

        KeyInput.destroyIfInitalized();

        MouseInput.destroyIfInitalized();

        JoystickInput.destroyIfInitalized();

      

   }



   protected void update(float interpolation) {

      

      timer.update();

      tpf = timer.getTimePerFrame();

      GameStateManager.getInstance().update(tpf);

      

   }

   

   protected final void render(float interpolation) {   

      

      display.getRenderer().clearBuffers();   

      GameStateManager.getInstance().render(tpf);

      

   }

   public static void exit() {

      finished = true;

      

   }



}


import java.awt.Color;

import javax.swing.JButton;

import com.foosball.main.MainGame;
import com.jme.app.StandardGameState;
import com.jme.input.InputHandler;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.MouseInput;
import com.jme.input.action.InputActionEvent;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.state.LightState;
import com.jme.system.DisplaySystem;
import com.jmex.awt.swingui.JMEAction;
import com.jmex.awt.swingui.JMEDesktop;


public class MainMenuState extends StandardGameState {
   
   private DisplaySystem display = DisplaySystem.getDisplaySystem();
    private InputHandler input;
    private Node menuNode;
    private static JMEDesktop desktop;
    private final JButton exitGameButton ;
   
    public MainMenuState(String name) {
        super(name);

       exitGameButton = new JButton( "Exit Game" );
       
        menuNode = new Node("menu node");
        menuNode.setCullMode(Spatial.CULL_NEVER);
        menuNode.setLightCombineMode(LightState.OFF);
        menuNode.setRenderQueueMode(Renderer.QUEUE_ORTHO);
       
        initInput();
        initMenu();
       
    }
   
   public void onActivate() {
      display.setTitle("Main Menu");
      super.onActivate();

   }
   
   protected void initInput() {
      input = new InputHandler();
      
      KeyBindingManager.getKeyBindingManager().set("exit_game",
                KeyInput.KEY_ESCAPE);
      
   }
   
   private void initMenu() {
      
          desktop = new JMEDesktop( "desktop" );
          desktop.setup( 420, 200, false, input );
          desktop.getLocalTranslation().set( display.getWidth() / 2 , display.getHeight() / 2, 0 );
          
          desktop.getJDesktop().setBackground( new Color(.6f, .6f, .6f, .6f ) );
          menuNode.attachChild( desktop );
          
          exitGameButton.setSize( 300, 200);
          
          desktop.getJDesktop().add(exitGameButton);
          desktop.updateRenderState();
             desktop.updateGeometricState(0,false);
           desktop.getJDesktop().repaint();
          
             // action that gets executed in the update thread:
              exitGameButton.addActionListener( new JMEAction( "my action", input ) {
                  public void performAction( InputActionEvent evt ) {
                     
                     MainGame.exit();
                      menuNode.updateRenderState();
                  }
              });
             
          MouseInput.get().setCursorVisible(true);
           menuNode.updateRenderState();
           menuNode.updateGeometricState(0, false);
      
   }
   public void cleanup(){
      
         desktop.dispose();
   }
   protected void stateUpdate(float tpf) {
      input.update(tpf);
      
      
      if (KeyBindingManager.getKeyBindingManager().isValidCommand(
                "exit_game", false)) {
            MainGame.exit();
        }
   }
   protected void stateRender(float tpf){
       display.getRenderer().clearBuffers();
       display.getRenderer().draw(menuNode);
      
   }
}


I don't have a clue…

Please check if the JMEDesktop tests run fine for you. If yes, maybe you are setting it up differently?

Looks ok to me :expressionless:



To figure it out try the following: replace the the JMEDesktop by a Quad of the same size. Make sure that you see that one. When you do put a texture on it - should still be ok. Then replace with JMEDesktop again. If it's not visible after that the texture isn't painted - post back here then. I suspect the problem being somewhere before that :slight_smile:

I replaced desktop with a quad and I saw the quad no problem. I then added a texture and it was fine. I removed quad and put JMEDesktop back in and it was still invisible. then I tried adding both at same time, when I did that I got the button to show up on top of the quad, but as soon as I remove quad the JMEDesktop goes invisible.

sounds like culling - try setting CULL_NEVER on the desktop, too. (I thought the whole branch would not be culled if menuNode had that set :?)

Or apply model bounds (e.g. BoundingSphere, not sure BBox will work)…

I tried

desktop.setCullMode(Spatial.CULL_NEVER);

and

desktop.setModelBound(new BoundingSphere());

          desktop.updateModelBound();

and still nothing.

hmm, no idea then. Seems you have to step through the draw(menuNode) method and have a look where it bails out…

well, I tried stepping through the draw() method and everything looked okay, no obvious reason why its not drawing. It doesnt seem to be culling the desktop as far as I can tell. I have no clue, im going to keep messing with it though maybe I can figure something out.

I saw something similar at work but it was only evident on my mac.  I was using a semi transparent frame as a console.

Im in Linux, but I also tested the same app in windows and got the same results. I guess for now ill just put my JMEDesktop on top of a quad, I can easily remove it later.

sounds like culling
I think you are right irrisor, I can recreate this bug by culling the desktop and quad when they do show. So now I just have to figure out where the desktop is getting culled and why.

things are getting worse, now I cant even create a JMEDesktop in my game without an error. I havent changed anything in my JMEDesktop creation I just updated from jme 1.0 to cvs version. I get error saying I should create my JMEDesktop in swing thread :? I tried it just for kicks and got a hot spot error. I dont know whats going on here, but im having a JMEDesktop meltdown. this error is not from example code in previous post but its from an example very similar, the JMEDesktops are created the same.

java.lang.IllegalStateException: not in swing thread!
   at com.jmex.awt.swingui.JMEDesktop.dispatchEvent(JMEDesktop.java:620)
   at com.jmex.awt.swingui.JMEDesktop.setFocusOwner(JMEDesktop.java:839)
   at com.jmex.awt.swingui.JMEDesktop.setup(JMEDesktop.java:373)
   at com.jmex.awt.swingui.JMEDesktop.<init>(JMEDesktop.java:287)
   at com.jmex.awt.swingui.JMEDesktop.<init>(JMEDesktop.java:266)
   at com.foosball.menu.EnterIPState.buildGUI(EnterIPState.java:57)
   at com.foosball.menu.EnterIPState.<init>(EnterIPState.java:44)
   at com.foosball.menu.MainMenuState$6.performAction(MainMenuState.java:253)
   at com.jme.input.ActionTrigger.performAction(ActionTrigger.java:264)
   at com.jme.input.util.SyntheticTrigger.performAction(SyntheticTrigger.java:43)
   at com.jme.input.InputHandler.update(InputHandler.java:368)
   at com.foosball.menu.MainMenuState.stateUpdate(MainMenuState.java:311)
   at com.jme.app.StandardGameStateDefaultCamera.update(StandardGameStateDefaultCamera.java:90)
   at com.jme.app.GameStateNode.update(GameStateNode.java:71)
   at com.foosball.main.MainFoosballGame.update(MainFoosballGame.java:333)
   at com.foosball.main.MainFoosballGame.start(MainFoosballGame.java:119)
   at com.foosball.main.MainFoosballGame.main(MainFoosballGame.java:81)