Reusing Graphics

Hi,

If rendering’s being done in full screen mode with a BufferStrategy, does the Graphics have to be retrieved and disposed of every frame – i.e., getDrawGraphics(), render, dispose? Can the same Graphics be stored and reused over and over without disposing if the screen isn’t resizeable, etc?

Also, can it be reused if the display is in a normal resizeable window (Frame)? I’ve done this in a Canvas that wasn’t being resized and didn’t seem to have any problems, but I’d like to know what’s correct in the above situations.

Thanks,
Derek

Can the same Graphics be stored and reused over and over
without disposing if the screen isn’t resizeable, etc?

Yes. But it isn’t any faster (you also don’t prevent any garbage) and it can behave very odd under mac os (eating ram until you hit an OutOfMemoryException).

So. Don’t do it.

Always get, draw and dispose.