I'm having trouble figuring out how to switch over to the use of active rendering and taking advantage of BufferStrategy. Was wondering if I could use this thread to get some help as I try to do this!
As a first step, all rendering code has been put into draw(g2) methods (where g2 is a Graphics2D object), with one exception. I have a three JPanels where in each I have written a render(g2) method. Of these JPanels, only one is showing at any one time.
In the gameloop, I call the render(g2) for the JPanel that is showing, and it handles calls to all draw(g2) methods associated with that JPanel. I also left in the paintComponent(g) method in these JPanels that I was previously using, and now have these calling the render(g2) method for that JPanel.
The hope was that by doing this, I would be following the first item of advice in the tutorial that states "Don't put drawing code in the paint routine."http://docs.oracle.com/javase/tutorial/extra/fullscreen/rendering.html
When I follow the second bit of advice: "setIgnoreRepaint(true)" on the JPanels, the following problem occurs: the JMenuBar that is associated with that JPanel will not repaint after minimizing and restoring.
How are components "repainted" when using active rendering? I tried including a call to paintComponents() in the render(g2) method, and also tried menuBar.paintComponents(). These would thus be called with each gameloop.
Any thoughts? Any suggestions on guidelines as to how to go through this conversion process?
Motivation: I'm currently hovering around 50% cpu on this game, would like to make it more efficient. (Pentium 4, 3.2 GHz, 3 GB Ram, dual core.) There's also a graphics glitch that is occurring which I was thinking might go away or be easier to deal with if the game were using active rendering, and some additional load I'd like to put on the graphics if possible (but not absolutely necessary).
I'm looking at the final product running as either an Applet or Application. (Hexara WIP)