flickering with Animator

Hi

With the help of other java-gaming.org members I got my jogl swing project working.

However, on adding a menubar and other widgets I now have a flickering effect when I select a menu item from the menubar.

The code below is basically the SimpleJOGL project code, with the animator object now made a field member.

If I comment out the last line [ie; mAnimator.start(); ] the flickering stops. Unfortunately, so does my opengl rendering!

Has anyone seen this behaviour before? I did a search for “animator” and “flickering” but no previous posts.

Cheers

Graham

public void initialise()
{
    initialiseCanvas();
    initialiseAnimator();
     
    // window listener
    addWindowListener(new WindowAdapter()
    {

        @Override
        public void windowClosing(WindowEvent e)
        {
            // run this on another thread than the AWT event queue to make sure the call to Animator.stop() completes before exiting
            new Thread(new Runnable()
            {

                public void run()
                {
                    mAnimator.stop();
                    System.exit(0);
                }
            }).start();
        }
        
    });

    // start animator
    mAnimator.start(); 
}

Maybe try running it with this command:

java -Dsun.awt.noerasebackground=true -jar MyJar.jar

I would expect this to be the problem because when you use the menu it redraws the frame, but I don’t know. Why does it matter if it flickers during the menu anyway? If they’re using the menu, they aren’t looking at the game part. Maybe you could stop animation while they are in the menu (using a listener).

Hi

Thanks for your reply.

I should have clarified that the flickering is on the menubar items. It is so bad that a user is unable to select a menu item.

I could try temporarily stopping the animator while the menubar has focus but I think a user would expect the rendered model to continue as normal irresepective of whether a user has hovered over the menubar.

Graham

Are you using a GLJPanel or a GLCanvas? If you’re using a GLCanvas, try switching to GLJPanel, or tell swing to use heavy weight components. If this doesn’t work, I think the only option is to pause rendering while you have the menu up (you don’t have to clear the render, and since the user isn’t interacting with what’s rendered, they shouldn’t see any difference unless it’s animated).