
Originally Posted by
Shaggy Hiker
Could you expand a bit on that? I haven't seen an Update(), nor am I quite clear what data you are talking about storing in an array. The way I was doing this with GDI+ was that for each object I created an array of 5 (or maybe 6, I forget) different images, one for each zoom level. Since most objects don't change, all I had to do on zooming was swap in the correct image. If some object changed, then the image list for that particular object was invalidated, which meant that the current image was drawn, but the other 4 zoom levels had to be drawn on demand when the user zoomed in or out. This worked well, since the number of changes was small, so the number of invalidated image lists was small, and the number of images that had to be drawn at each zoom level was small. The problem arose when the user made some fundamental change that forced the system to redraw ALL images at once. That could cost 20 seconds.
Using the XNA system, I scrapped the cached image lists. On each zoom in or out, all the objects get redrawn to the new level. That was too slow to be acceptable using GDI+, but happens almost instantly under XNA. If I could cache the generated images as Texture2D, I could use the same cached image list design, which would increase speed even further, but that may not be worth doing, since the performance appears to be excellent already (except for the fact that I can't draw correctly).
I should add that the drawing is only a portion of the total time. It was a big portion, but only a portion. Therefore, there is a limit as to how much performance advantage can even be realized by making changes to the drawing. For example, a small but measurable part of the time spent in the GDI+ routines was spent figuring out what needed to be drawn and where. That wasn't a big deal in GDI+, because the caching meant that I could figure it out once then not deal with it again. Under XNA, where each object gets drawn each time the user zooms in or out, I am currently recalculating where to draw everything with each zoom (turn of the mouse wheel). There is no need to do that, anymore, so I can shift the recalculation out of the drawing routine to the events that are fired when an action changes what gets drawn. That will speed up the drawing routine, since it won't have to calculate where to draw anymore, it can just paint the textures into place.