No problem with Animator ?

Hello,

I’m using an animator with pbuffers.
I would like to animate a pbuffer in order to take a screenshot and then stop the animation, each time I need a screenshot.

code example :

// pbuffer is a GLPBuffer. pbuffer is initialized.

animator.add( pbuffer ) ;

animator.start() ;

while( !workDone )
{
try
{
System.out.println( “waiting work done.” );
wait() ;
}
catch (InterruptedException e){}
}
workDone = false ;

System.out.println( “get buffered image.” );
BufferedImage image = pbuffer.getBufferedImage() ;

System.out.println( “remove pbuffer of the animator.” );
animator.remove( pbuffer ) ;

animator.stop() ;

But, animator.remove() method doesn’t stop my pbuffer (the animator keeps calling the display() method of the pbuffer GLEventListener).
And, when I call the animator.stop() method, I can’t call animator.start() again.

Did I make a mistake ?

Thanks

Also, when I want to start my animator again or add my pbuffer again in the animator, I obtain this kind of errors :

javax.media.opengl.GLException: javax.media.opengl.GLException: Error making context current: 0
at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:271)
at com.sun.opengl.impl.GLPbufferImpl.maybeDoSingleThreadedWorkaround(GLPbufferImpl.java:199)
at com.sun.opengl.impl.GLPbufferImpl.display(GLPbufferImpl.java:88)
at com.sun.opengl.util.Animator.display(Animator.java:144)
at com.sun.opengl.util.FPSAnimator$1.run(FPSAnimator.java:95)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: javax.media.opengl.GLException: Error making context current: 0
at com.sun.opengl.impl.windows.WindowsGLContext.makeCurrentImpl(WindowsGLContext.java:169)
at com.sun.opengl.impl.windows.WindowsPbufferGLContext.makeCurrentImpl(WindowsPbufferGLContext.java:102)
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:127)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
at com.sun.opengl.impl.GLPbufferImpl$DisplayOnEventDispatchThreadAction.run(GLPbufferImpl.java:233)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Thanks

Sorry, I forgot a very big detail !

This code works in a basic application.

But, it doesn’t in a servlet managed by JBoss.

Thanks

You can cause a pbuffer to render itself once just by calling display(). You don’t need to start up an Animator to do so. If you remove the Animator, does it change the behavior?

What about if you reuse the pbuffer over and over again? Or are you already doing so?

Are you causing -Dsun.java2d.noddraw=true to be passed to the JVM running JBoss? Are there any GUI elements (on-screen windows, etc.) created by that JVM?

What graphics card and OS are you running? Are you using the latest drivers from your graphics card’s vendor?

I’m very grateful that you answer me, Ken !

I removed the Animator, so I replaced my code by the following one :

pbuffer.display() ;

System.out.println( “get buffered image.” );
BufferedImage image = pbuffer.getBufferedImage() ;

But, I can call the display() method only once time because after I obtain the following error :

Exception in thread “Thread-21”
javax.media.opengl.GLException: javax.media.opengl.GLException: Error making context current: 0
at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:271)
at com.sun.opengl.impl.GLPbufferImpl.maybeDoSingleThreadedWorkaround(GLPbufferImpl.java:199)
at com.sun.opengl.impl.GLPbufferImpl.display(GLPbufferImpl.java:88)
at com.rfs.j2ee.KiWI.web.servlet.graph3d.PBufferManager.executePBuffer(PBufferManager.java:106)
at com.rfs.j2ee.KiWI.web.servlet.graph3d.Process.run(Graph3dImage.java:434)
Caused by: javax.media.opengl.GLException: Error making context current: 0
at com.sun.opengl.impl.windows.WindowsGLContext.makeCurrentImpl(WindowsGLContext.java:169)
at com.sun.opengl.impl.windows.WindowsPbufferGLContext.makeCurrentImpl(WindowsPbufferGLContext.java:102)
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:127)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
at com.sun.opengl.impl.GLPbufferImpl$DisplayOnEventDispatchThreadAction.run(GLPbufferImpl.java:233)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

I already reuse the same pbuffer, in order to increase the processing speed.

I don’t cause -Dsun.java2d.noddraw=true.
I don’t have any GUI elements created by the JVM.
My graphics card is an Intel 82845G/GL/GE/PE/GV Graphics Controller.
The drivers are the lastest ones.
And, I work on windows XP professional sp1.

I already made many tests of the same code, on the same computer, in a classic java application and it worked. Also, JBoss is installed in local. So, I think that the graphics card isn’t the problem.

Maybe, it’s a problem with JBoss, and not with Jogl…

The only way I found to resolve this problem is to create an Animator, and add a pbuffer to it. Then, I just modify the properties of my GLEventListener and take the screenshot. But, once time the animator is started, it never stop !

No problems with the Animator restart (never stop).
No problems with the pbuffer readdition in Animator (never remove).

–> I can reuse these two objects to take screenshots over and over again.

But, this way isn’t very clean (sure!) and I can’t use more than one pbuffer. So, my web application will be slow if many users launch the servlet at the same time…

You need to pass -Dsun.java2d.noddraw=true to the JVM for all JOGL applications on Windows in order to guarantee that they work correctly.

I strongly suspect the problem is with Intel’s graphics drivers and probably the creation of multiple pbuffers. I am guessing JBoss is instantiating multiple copies of your application behind the scenes causing multiple pbuffers to be created. Knowing this you might be able to create a similar multithreaded test case reproducing the problem and if you can I would suggest you send it to Intel.

Another suggestion would be to invest in a cheap NVidia graphics card, which should solve all of your problems.