Well, I am writing a game / engine in 2d in , and I have gotten quite far, my problem is I was reading some stuff about the engine Slick2D, which is pretty much one of the most popular 2d engines in Java, I noticed that the creator said he had used JOGL(Java OpenGL) to render his 2d graphics. In my game engine, I have classes such as Unit, Builing, Tile, Effect which all store cropped images of a tile sheet(standard in 2d), but the images are stored as ImageIcons for object serialization. I really want to optimize the graphics rendering, so that minimal processing is required, and I dont want to call repaint for EVERY single little change, and repaint the entire thing. To make sure I dont repaint EVERYTHING just because of say, ONE effect that was added, I was thinking of making sure I render the TILE layer only once, and the other layers such as Buildings and Effects should be stored in a Cache.. If the current / updated Vector of Buildings is NOT equal to the cached vector of buildings, then I will render it, I wanted to ask if this was a good way of saving time and processing. Also, I wanted to know, I use the Graphics of the Canvas, as well as the paintIcon method of the ImageIcon class to actually PAINT the images onto the canvas, should I change this method and use JOGL? What is the most efficient way of STORING the image information, making sure that the variable that it is stored in is serializable.

Currently, I load the image, store the cropped 32x32 tile into a ImageIcon variable in a class, and then the Canvas makes sure there is a difference from the previous paint, and then it calls the paintIcon method of the ImageIcon, or it just paints it in the canvas itself. What is the most efficient method to this! Thank you!

Nope, there is no performance problem at all, but that is the thing I am trying to avoid here, I dont ever WANT to get one, so I was just wanting to know what is the most efficient method in rendering and storing 2d graphics, that way I would know for a fact that any performance issues does not lay in that portion of the engine :). Thank you!

By all means have fun and learn by doing that. However, I would say that
1. There is no single "most efficient" way; it will depend on exactly what you are doing
2. In practice you need to code as clearly as possible, test and run it (optimising before dugging is guaranteed to be a waste of time), then IF there is a problem profile the code to see exacly whaere the problem is, finally optimise the code where the problem is.
Recent versions of Java have a load of optimisiation built into Swing's screen painting, most of it hidden from the ordinary Java programmer - so you may find that an apparently good idea actually makes things worse because it conficts with or disables a built-in optimisation.

Oh wonderful, so what you are telling me is that my method of storing cropped images in ImageIcons, caching the vectors and checking for changed, then displaying only the vector with change is the proper method to do this? I was thinking all along that JOGL was the most "efficient" method, but if your saying that this is fine, then I am happy because now I do not have to rewrite all that code :D

I'm not in a position to say definitively if your method is "the proper method" or not, but it sounds like you have chosen an implementation that seems simple/clear enough, and should avoid any obvious effiency problems. My opinion is that you have done the right thing, and should now move on. If, and only if, you get a problem you should re-visit this.

SWEET, alright thank you :) , I never have had any problem, I was just asking is all. :) Thread solved then

This question has already been answered. Start a new discussion instead.