Constant background

I have a background where there are lines, which I can draw using GL_LINE. An object, a squre block, moves in this background. I guess it is efficient to redraw only the object when it moves, since the background does not change. Is there any way of doing this?

There are a couple ways to do this. One way is to use a display list to draw the portions of your scene that don’t change. In your setup routine, put the code that draws the lines in a display list in retained mode (as opposed to immediate mode). Then in your display routine, call the display list followed by the code that draws the moving square. This will give you a big performance boost because even though you’ll call the display list each time through your display routine, you’ll effectively only have drawn the background once, when you set up the display list.

Thank you very much. It was really helpful.