[SDL] Bad performence problems
darkmatter at freeuk.com
Thu Aug 10 18:15:13 PDT 2006
> I have been working on this one algorithm for days to try and make it work at
> a reasonable speed but to no avail...was hoping meyb u guys could help!
> :)....firstly my coputer specs: athlon 2100xp 1gig ram r9800pro gfx
> At the moment i am writing a top down shooter, and i am
> trying to write an algorithm that darkens the whole screen apart from a
> circular area around the player using the folliwng algorithm that i made:
Don't use getPixel(), do it with a memory read.
Calculate your buffer offset ONCE per Y line instead of every time.
Don't mix float and double. Stick to float.
Hm, that code seems to have an error. The only pixel write done is
pixels[ofs] = pixels[ofs]/2;
which means all that work calculating a pixel is never used!
I'm wondering if you are better off using alpha somehow to achieve this.
More information about the SDL