Hello. It's been a long time since I last wrote here.
I'm trying to integrate fenggui in my warehouse application created some time ago, but I'm having some difficulties.
initialization part
setDefaultEnvironement();
new Vis3DConfig(this);
ModelLoader.loadTextures();
ModelLoader.cacheModels();
warehouses = WarehouseXMLLoader.load(doc);
//set first warehouse as default
warehouse = (WareHouse)warehouses.get(0);
warehouse.startControllers();
doc = null;
warehouse.setDefaultThread(Thread.currentThread());
buffer = new FrameBuffer(resWidth, resHeight, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL, IRenderer.MODE_OPENGL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
for some reason if i dont put sleep here i get an exception
java.lang.IllegalStateException: Mouse must be created.
at org.lwjgl.input.Cursor.getMaxCursorSize(Cursor.java:136)
...
--------ADDED FROM HERE-------
try
{
Thread.sleep(2000);
}
catch (InterruptedException ie)
{}
LWJGLBinding binding = new LWJGLBinding();
desk = new org.fenggui.Display(binding);
buildGUI();
--------ADDED UNTIL HERE-------
render();
adding test gui widget
Window mw = new Window();
desk.addWidget(mw);
mw.setTitle("TEST EMPTY WINDOW");
mw.setSize(300, 100);
mw.setX(100);
mw.setY(100);
desk.layout();
rendering part
while (running)
{
poll();
synchronized(warehouse)
{
warehouse.doMovement();
buffer.clear();
warehouse.renderScene(buffer);
warehouse.draw(buffer);
}
buffer.update();
here i get an exception
java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glPushAttrib(GL11.java:2495)
at org.fenggui.render.lwjgl.LWJGLOpenGL.pushAllAttribs(Unknown Source)
at org.fenggui.Display.display(Unknown Source)
...
--------ADDED FROM HERE-------
desk.display();
--------ADDED UNTIL HERE-------
addBliting(buffer);
buffer.displayGLOnly();
second = System.nanoTime();
actualSleepTime = sleepTime - (second - first);
if (actualSleepTime < 0)
{
actualSleepTime = 0;
}
long actualMilsec = (long)((float)actualSleepTime/1000000f);
int actualnanoSec = (int)(actualSleepTime%1000000);
try
{
Thread.sleep(actualMilsec, actualnanoSec);
}
catch (InterruptedException ie)
{}
first = second;
}
I checked in fenggui source and it is thrown here
public void pushAllAttribs() {
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
}
Anyone know what I'm doing wrong?
No idea. Raft did some tests with FengGUI: Maybe he can help. About the first exception: This somehow looks as if some thread in the background takes some time to create the mouse, which it doesn't have without the sleep. But that makes not much sense to me. Which thread should that be? At least none from jPCT...there is none that does this...unless you are using Config.useMultipleThreads...are you?
OMG Egon....
Yes I changed useMultipleThreads property to false and it solved both exceptions.
Thank you very much.... I was banging my head over that for the whole day :)
When using multiple threads, the actual rendering (as well as the initialization) happens in a thread of its own. Which also means that this thread has the OpenGL context. To combine FengGUI with this, you'll have to attach an IPaintListener to the buffer and do the GUI setup and rendering in the call back methods. That should work (I've never tried it)...or you don't use multiple thread any longer when using FengGUI.