#48 Poor performance when drawing fog

v1.0 (example)
closed-fixed
RichieQ
None
5
2014-07-16
2014-05-30
Edd Barrett
No

Hi,

I notice that dunelegacy lags quite badly on my modern x230t thinkpad running OpenBSD, but only when fog of war is enabled and when I am zoomed right out.

A friend and I did some experimentation and found that the lines of code which caused the lag are (in the fog loop in Game.cpp):

SDL_Surface** hiddenSurf = pGFXManager->getObjPic(ObjPic_Terrain_Hidden);

and

SDL_UnlockSurface(hiddenSurf[currentZoomlevel]);

Assuming that hiddenSurf does not change in all iterations of the fog loop, we can move the allocation, lock and unlocking of hiddenSurf outside the fog loop to remove the lag. The attached patch does exactly this and it appears to work. The question now is, is it correct?

Cheers!

1 Attachments

Discussion

  • Edd Barrett

    Edd Barrett - 2014-07-15

    Anyone?

     
  • RichieQ

    RichieQ - 2014-07-16

    The patch was not 100% correct as the surface was also used for blitting inside the loop which is not possible when being locked. But I included your idea of moving the locking outside the inner loop.

     
  • RichieQ

    RichieQ - 2014-07-16
    • status: open --> closed-fixed
    • assigned_to: RichieQ
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks