[SDL] Bad performence problems
Peter Mulholland
darkmatter at freeuk.com
Thu Aug 10 18:15:13 PDT 2006
darkplastic wrote:
> 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
> card.....
> 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:
>
<snip>
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.
Pete.
More information about the SDL
mailing list