[SDL] single pixel drawing

Robert Wohleb rwohleb at r2tech.com
Tue Jul 16 10:30:01 PDT 2002


One of the best ways to add some optimizations to pixel operations is to use
bit-shifting when doing pointer calculations. Bit-shifting mixed with
addition can add up to a big bonus when you have to do a lot of pointer
calculations per frame.

~Rob

-----Original Message-----
From: Loren Osborn [mailto:linux_dr at yahoo.com]
Sent: Monday, July 15, 2002 1:53 AM
To: sdl at libsdl.org
Subject: Re: [SDL] single pixel drawing


While I agree that function calling overhead can be
expensive, decalring a function as "inline" largely
eliminates the majority of this.

That leaves two other potential bottelnecks:
pixel addressing (which you discussed).  While the
multiplies can be expensive, they can only be replaced
with faster operations (like adds and increments) when
the pixels are drawn in a predictable shape (such as a
curve or a line).

The bottleneck you did not address is converting the
desired pixel color into the pixel format of the
surface. This can be especially redundant if the same
color is being converted repeatedly. (Which is why I
advised caching)...

I hope that helped,

-Loren
--- Atrix Wolfe <Atrix2 at cox.net> wrote:
> Drawing single pixels at a time is inherantly slow
> and if at all possible it
> should be avoided.  That aside im going to try to
> explain as best as i can
> and hopefully itll make sense to you. The fastest
...[truncated}...


__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com

_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl




More information about the SDL mailing list