Display list only being called once

Hi,

I have a Swing GUI with a glCanvas on it and when I press a button on the Swing GUI I would like the canvas to redraw as the button press changes what is drawn to the scene. I can get this working fine when I don’t put my drawing code in a display list, but as soon as I use a display list the button press does nothing as if the list isn’t being called. I have an animator thread that is constantly calling the display() method which contains my display list. I know display is being called by Animator repeatedly because if i put debug statements in there it prints them out continuously. Can someone please advise whether or not there is a problem with my display list or offer some suggestions otherwise. If you require more information please ask.

In my init method I create the display list:

displayList = gl.glGenLists(1);
gl.glNewList(displayList, GL.GL_COMPILE);
// draw scene
gl.glEndList ();

In my display method I call it:

gl.glCallList(displayList);

If I remove the display list code and just use the drawing code in display(), the scene gets redrawn correctly after the button press. But I would like to use a display list.

Thanks in advance :slight_smile:

Well, I did exactly what you describe in my code, and it worked correctly… What do you see when you try to draw the display list - does it show nothing at all(i.e. a bakcground that matches the glClearColor color), your scene without the appropriate change,or something else unexpected?

And what is it that click the button changes? Is it something that changes in the calls inside the display list? If so, you need to re-compile the display list every time you make that change, otherwise it will call the old display list… any variables that are accessed while setting up the display list are java variables, so they aren’t reflected in the display list on the graphics card…

“Well, I did exactly what you describe in my code, and it worked correctly… What do you see when you try to draw the display list - does it show nothing at all(i.e. a bakcground that matches the glClearColor color), your scene without the appropriate change,or something else unexpected?”

I see the same scene that was there when it was clicked. The mouse click should toggle the visibility of one of the objects in my scene. In other words the scene is displaying correctly, but the visibility of the object in question does not change.

“And what is it that click the button changes? Is it something that changes in the calls inside the display list? If so, you need to re-compile the display list every time you make that change, otherwise it will call the old display list… any variables that are accessed while setting up the display list are java variables, so they aren’t reflected in the display list on the graphics card…”

The mouse click toggles the visibility of one of the objects in my scene which has a draw method that is called in the display list. Without using the display list and just using the drawing code, this toggles the visibility as expected. The mouse click sets the visibility of the object to the opposite of whatever it was when it was clicked. The draw method checks if the object is visible before drawing it.

If I understand your code flow properly, the problem is that you’re using the button to change the program state in java, but then you aren’t recompiling the display list. Once you set up a display list, it gets sent off to the graphics card and cannot be dynamically updated without replacing it with another display list. When you click on the button to toggle visibility, you need to tell you code to go back and re-compile the display list (I just have a boolean that indicates if the display list should be drawn, and call the display list code from witin an if statement in the display mode that sets the boolean false at the end. That way, you can be sure that the list will be updated whenever you toggle the boolean).