Animator object utilizes all CPU

Try putting -DATI_WORKAROUND=false on the command line.

It did not change anything. Also, when stopping the program with ctrl + C I encounter this exception (maybe it"ll help you)

Throwable thrown during display:
net.java.games.jogl.GLException: Error swapping buffers
at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.swapBuffers(WindowsOnscreenGLContext.java:140)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:292)
at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:208)
at net.java.games.jogl.GLCanvas.display(GLCanvas.java:75)
at Renderer.run(Renderer.java:62)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:280)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:135)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.j
ava:65)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.
java:142)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:166
)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)

Try adding the following snippets of code to your application.


// At the top of your class
import java.lang.reflect.*;


// Before you visualize the window (and definitely before you start
// the Renderer)
try {
  Method method = GLCanvas.class.getDeclaredMethod("willSetRenderingThread", new Class[] {});
  method.setAccessible(true);
  method.invoke(canvas, (Object[]) null);
} catch (Exception e) {
  e.printStackTrace();
}

No changes at all :(. The only thing worth mentioning - new code has the same effect as canvas.setNoAutoRedrawMode(true); (that helped me to visualize the window the first time)

Are you running all of the following?

[] the snippet of new code (willSetRenderingThread())
[
] setRenderingThread()
[] setNoAutoRedrawMode(true)
[
] -DATI_WORKAROUND=false
[*] -Dsun.java2d.noddraw=true

Basically given that you’re seeing bad behavior when doing work on the AWT thread, you want to try to get work off the AWT thread and onto your animation thread. I suspect a driver bug related to multithreading; the only question is how to work around it.

Yes, I run everything.

Thanks for advice. Hope with your help, guys, I’ll make it work sooner or later.

I don’t know what other significant differences there are between JOGL’s Animator class and nnevatie’s Renderer class.

What happens if you switch back to using the Animator and do a Thread.sleep() at the end of your display() method? Does the CPU consumption go down, and does your scene animate properly (instead of getting stuck in wglMakeCurrent?

I switched back to Animator class, and added Thread.sleep(…) to the end of my display() method.
What is happening after program starts, by steps:

  1. CPU Consumption is small (as it should be), and everything is drawn ok.
  2. Window is not responding - movement, etc.
  3. If I switch to another application, and go back, scene is redrawn, but window border and title - not, and then cpu full consuming starts.

As you can see, behaviour is exactly the same as before.
After last changes there is no difference in work when using Animator or nnevatie’s Renderer.
So, initial problem (cpu consumption) has now two solutions, but the new one (with the frame) still exists.

Have you tried -DATI_WORKAROUND=true in addition to the other command-line arguments and program changes?

Could you try running with a 1.4.2 JDK? I don’t think there should have been any changes in the Windows AWT in 1.5 that could have affected behavior like this, but I do most of my testing with 1.4.2.

Are you running the latest drivers for your board?

Is your machine a multiprocessor? If so, have you tried disabling one of the CPUs in boot.ini?

Thanks everyone! Now it works! Suggestions were right - ATI’s drivers are …!! well, not very good. As I’ve written before, I experimented with different drivers (4 ATI drivers), but have forgotten to check work with default Microsoft driver. And - everything works perfectly now! I’m really sorry that I have made so much disturbance for everyone posting these endless problem messages.
The program works fine with both Animator and nnevatie’s Renderer.

Thank you very much guys!

…These problems almost made me insane (I laughed hysterically after the program started working at last) :slight_smile:

Again, thanks a lot!

Good to hear it’s all working now. Are you also able to run the Renderer class now? This is interesting information for me as well, because it helps to improve the compatibility of my code :).

With Renderer class everything works fine :slight_smile: