Problems setting up GBui

Hello people.



I want to make a HUD for my Jmonkey app and found that JMEDesktop is slow as hell. As GBUI seems to be the semi-official alternative GUI, I looked into that.



So I downloaded the jar from http://samskivert.com/code/jme-bui/ and added that to my project in Eclipse. I constructed the following gamestate:



import com.jmex.bui.BWindow;

import com.jmex.bui.BuiSystem;

import com.jmex.bui.background.BBackground;

import com.jmex.bui.background.BlankBackground;

import com.jmex.bui.layout.GroupLayout;

import com.jmex.game.state.BasicGameState;



public class HudStateWithGBui extends BasicGameState {



public HudStateWithGBui() {

super("hudState");



BWindow window = new BWindow(BuiSystem.getStyle(), GroupLayout.makeVStretch());

window.setSize(100, 100);

window.setLocation(100, 100);



BBackground background = new BlankBackground();

window.setBackground(0, background);



BuiSystem.getRootNode().addWindow(window);

rootNode.attachChild(BuiSystem.getRootNode());



}



}



However, with this gamestate attached and activated, the application hangs (and it runs fine without this gamestate, so the problem should lie here). I get a "source not found" error.



Here's the call stack.



ClassLoader.defineClass1(String, byte[], int, int, ProtectionDomain, String) line: not available [native method]

Launcher$AppClassLoader(ClassLoader).defineClass(String, byte[], int, int, ProtectionDomain) line: not available

Launcher$AppClassLoader(SecureClassLoader).defineClass(String, byte[], int, int, CodeSource) line: not available

Launcher$AppClassLoader(URLClassLoader).defineClass(String, Resource) line: not available

URLClassLoader.access$000(URLClassLoader, String, Resource) line: not available

URLClassLoader$1.run() line: not available

AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]

Launcher$AppClassLoader(URLClassLoader).findClass(String) line: not available

Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available

Launcher$AppClassLoader.loadClass(String, boolean) line: not available

Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available

Launcher$AppClassLoader(ClassLoader).loadClassInternal(String) line: not available





So my question to the reader is: what am I doing wrong here? Should I integrate GBUi into JME in another way?


Let's start from the beginning…the jar you downloaded was for BUI…the GBUI jars are at http://code.google.com/p/gbui



the code you've written below shouldn't actually work with BUI b/c the BuiSystem is actually a product of my own mind for GBUI to extend a management system for all your display needs (ok, not really, but I was on a roll).



The way you have started is ok, but compare it to the tests in the gbui trunk and you'll see that you're not far off.



http://code.google.com/p/gbui/source/browse/trunk/test/java/com/jmex/bui/base/BaseTest.java

http://code.google.com/p/gbui/source/browse/trunk/test/java/com/jmex/bui/MenuTest.java



As you can see these don't use a GameState, but the Simple or BaseGame - however, the principle is very similar…



Can you post the rest of the code that you're using to integrate this class into your game?  That would help me look at what's going on better.


Thank you for your help. I have now downloaded the source code of GBUI via SVN and linked it to my project. However, I still have problems. I think it

We're using gbui with StandardGame in our project, so perhaps I could try to give a hint to what problems we encountered.

I don't think I've seen that example before, but I see it uses SimpleGame, as you're trying to use StandardGame, which is multi-threaded. This means that you need to inject some things into the OpenGL thread for them to work without errors.

We've found that you need to do this for many gui-related calls, as the gui is a visual interface and many calls deal with things that need to be drawn by the renderer thread.

I'm not sure this is your problem in this case, but you could try injecting at least your createGUI()-call into the OpenGL thread, by using the GameTaskQueueManager.update method.



Your stack trace mentions an NPE at BImage, line 488, which is (in my version):

_supportsNonPowerOfTwo = GLContext.getCapabilities().GL_ARB_texture_non_power_of_two;


It clearly has to do with OpenGL, although if it still throws an error when in the GameTaskQueueManager.update queue, I'm not sure what the problem might be.
Good luck!

Thank you very much, it works now!  :D



It was indeed an OpenGL thread problem. But luckily not the whole createGUI() had to be called from that thread.



Below is the GameTask code with wich it now works.

 

   try {
         GameTaskQueueManager.getManager().update(new Callable<Object>() {
            public Object call() throws Exception {
               
               window.add(btnExit);
               BuiSystem.addWindow(window);
               return null;              
            }
         });
      } catch (Exception e) {
         e.printStackTrace();
      }



I don