Author Topic: Improved globe performance when zoomed in  (Read 5291 times)

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Improved globe performance when zoomed in
« 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
« Last Edit: October 30, 2010, 02:05:51 pm by Daiky »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: Improved globe performance when zoomed in
« Reply #1 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

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Improved globe performance when zoomed in
« Reply #2 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?

Offline sir_nacnud

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Improved globe performance when zoomed in
« Reply #3 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.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: Improved globe performance when zoomed in
« Reply #4 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.