OpenXcom Forum

Contributions => Programming => Topic started by: Daiky on October 30, 2010, 01:50:21 pm

Title: Improved globe performance when zoomed in
Post by: Daiky on October 30, 2010, 01:50:21 pm
Adding two lines of code (to not draw text labels that are not on the screen), more than doubles the framerate when zoomed in.


Also you may want to do the same check in the cachePolygons function. The performance increase is amazing. But I don't want to do all the work for you :p
Title: Re: Improved globe performance when zoomed in
Post by: SupSuper on October 30, 2010, 04:44:15 pm
Funny, I would've expected SDL to automatically ignore anything outside a surface's area. Got to do all the work myself. :P
Title: Re: Improved globe performance when zoomed in
Post by: Daiky on October 30, 2010, 04:56:33 pm
well, SDL will probably not actually execute the drawing function.
But the other stuff like "Text *label = new Text(_res->getFont("BIGLETS.DAT"), _res->getFont("SMALLSET.DAT"), 80, 9, x - 40, y + 2);" is executed anyway, even for labels totally off-screen. It is creating massive amounts of new instances of Text there...
Not sure where label gets deleted again?
Title: Re: Improved globe performance when zoomed in
Post by: sir_nacnud on October 30, 2010, 08:22:51 pm
Looks like a memory leak in both the draw loop for country names and city markers.  I don't see the label pointer being stored anywhere, it just goes out of scope after each iteration.

Is there a reason to create a new Text object per item drawn?  Could you just create one object, then update the x position, y position, and the text each iteration.  These appear to be the only things changing.
Title: Re: Improved globe performance when zoomed in
Post by: SupSuper on October 31, 2010, 06:19:34 pm
Looks like a memory leak in both the draw loop for country names and city markers.  I don't see the label pointer being stored anywhere, it just goes out of scope after each iteration.

Is there a reason to create a new Text object per item drawn?  Could you just create one object, then update the x position, y position, and the text each iteration.  These appear to be the only things changing.
Most screens need to keep track of the text, but you're right the Globe doesn't, I'll get it fixed.