Hi,
I am trying to synchronize off-screen rendering myself (since
waitForOffScreenRendering doesn't work).
In following piece of code, MyOffScreenCanvas3D defines
blockingRenderOffScreen() which is supposed to block until rendering is
finished. Sync object provides dedicated lock and wait set.
Unfortunately, this generally won't work if blockingRenderOffScreen() is
called two times with less than 300 ms between the calls. (if there is >1
second, it seems to work most of the time...)
The problem is that for some reason notify() in renderingDone() is called
by some rendering thread while the original thread is still at point *A* in
code and this obviously causes wait() to block indefinitely. As this should
never happen (synchronized methods), either my code or java3d is buggy.
Any comments?
class MyOffScreenCanvas3D extends Canvas3D
{
Sync m_sync;
MyOffScreenCanvas3D()
{
super( /*some config*/ , true);
m_sync = new Sync(this);
}
public void blockingRenderOffScreen()
{
m_sync.startRendering();
}
public void postSwap()
{
m_sync.renderingDone();
}
/*
... rest of the class, nothing special here
*/
}
class Sync
{
Canvas3D m_canv;
Sync(Canvas3D canv)
{
m_canv = canv;
}
synchronized void startRendering()
{
m_canv.renderOffScreenBuffer();
// *A*
try {
wait();
}
catch (InterruptedException e) {}
}
synchronized void renderingDone()
{
notify();
}
}
-- Matti Hietaj�rvi
University of Oulu
Finland
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".