My game is running too slow.
When I run a profiler I see that graphics2d.paint() takes most of the cpu time. The size of the game panel is 1024*768.
I am double buffering and using BufferedImages created via GraphicsConfiguration.createCompatibleImage().
The game has several screens which include buttons and animations.
I am using Awt.Containers/Components for the different screens/game elements because its easier then to manage them on screen and also receive mouse clicks on the buttons.
In order to have to program paint only after I update the game I don’t forward the update() call in the double buffered screen to the paint() call but rather call the paint() method myself ( with getGraphics() )after each game update in the main run() loop. ( Active Rendering )
It seems to me like I’m painting a lot. Each screen has an 1024*786 background which I’m painting every iteration in the run() method. I have to paint at least some of that image again and again because I have animations playing in front of it.
I don’t want to use LWGL because I want the program to be multi platform. How much faster will the program run if I do switch to lwgl ?
Will abandoning AWT containers/components increase the game speed? If so is there any library for handling painting in a way that minimizes the number of paint calls/ minimizes the areas repainted?
Any suggestions?
Thanks.