pbuffer.isBufferLost() throws IllegalStateException

Started by Momoko_Fan, November 20, 2011, 00:04:12

Previous topic - Next topic

Momoko_Fan

This one is a little weird, here's the trace:

java.lang.IllegalStateException: The Drawable has no context available.
at org.lwjgl.opengl.DrawableGL.checkDestroyed(DrawableGL.java:152)
at org.lwjgl.opengl.Pbuffer.isBufferLost(Pbuffer.java:249)
at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:113)
at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:147)
[catch] at java.lang.Thread.run(Thread.java:722)


The relevant code is this:
if (pbuffer.isBufferLost()){
            pbuffer.destroy();
            try{
                pbuffer = new Pbuffer(width, height, pixelFormat, null);
                pbuffer.makeCurrent();
            }catch (LWJGLException ex){
                listener.handleError("Failed to restore pbuffer content", ex);
            }
        }

As you can see there's really no chance for this code to happen if the pbuffer is destroyed, since it is immediately recreated afterwards.

It seems like this might be a bug? What do you think?

EDIT:
Here's the original post:
http://jmonkeyengine.org/groups/android/forum/topic/cant-install-android-support/#post-151579
There are other additional errors after it, might help understand the issue.

spasi

AFAICT, the pbuffer was never created in the first place. See this one:

org.lwjgl.LWJGLException: Could not create Pbuffer
at org.lwjgl.opengl.WindowsPbufferPeerInfo.nCreate(Native Method)
at org.lwjgl.opengl.WindowsPbufferPeerInfo.(WindowsPbufferPeerInfo.java:47)
at org.lwjgl.opengl.WindowsDisplay.createPbuffer(WindowsDisplay.java:663)
at org.lwjgl.opengl.Pbuffer.createPbuffer(Pbuffer.java:234)
at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:219)
at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:190)
at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:166)
[catch] at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:116)
at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:147)
at java.lang.Thread.run(Thread.java:722)


The pbuffer being lost is not the same as being destroyed. You cannot call .isBufferLost on a destroyed, or (in this case) never created, pbuffer.

Momoko_Fan

That makes no sense. If I create a pbuffer with new Pbuffer() then it is created, if I call pbuffer.destroy() the pbuffer is destroyed. How can there exist a never created pbuffer that I can call isBufferLost() on?
Also the buffer can never be in a destroyed state, because in each instance where I destroy the pbuffer, I recreate it again.
Perhaps I am missing something obvious but I don't see it

spasi

This is what I think is happening:

- The original pbuffer was created successfully.
- At some point, .isBufferLost() returns true.
- You destroy the original pbuffer.
- You create another pbuffer, but an exception is thrown and the pbuffer variable continues to reference the original pbuffer.
- The next time .isBufferLost() is called on a destroyed pbuffer, so you get that exception.

Indeed, my previous reply wasn't accurate.