More antialiased linedrawing

Is there any chance or interest in having line drawing in the SDL library?
I’d be happy to SDL-ize it and submit it to the library. Obviously, I’d
have to make 8bpp, 24bpp, and 32bpp versions of the routines as well as
include my translucency and “normal” linedraws and of course clipping.

I tried WU antialiasing but it really looks bad. One side of the line
looks great, the other is just as stairstepped as the original
nonantialiased line. Yuck.

Anyway, this routine is only about 15% slower than a regular single pixel
draw, and it also includes gamma correction. The lines look really, really
sharp! Here is a segment when it’s an X major stepping, and I think I’ve
pretty much optimized it to the point it can be optimized, but I’d love
to hear any ideas from other experts in graphics. The only thing I’m
thinking now is that the 16bpp accesses kill the Pentium pipeline…

s32DistX = Distance between X endpoints
s32DistY = Distance between Y endpoints
pu16Buffer = Pointer to 16bpp surface
s32XSrc = Source coordinate (from X)
s32Temp = Y Step * pitch

if (s32DistX > s32DistY)
{
s32XCounter = 0;
s32Step = (s32DistY << 8) / s32DistX;
s32DistX <<= 8;
s32XDest -= s32XSrc;

while (s32XDest)
{
u32Intensity1 = sg_u32GammaPositive[s32XCounter & 0xff];
u32Intensity2 = sg_u32GammaNegative[s32XCounter & 0xff];

  *(pu16Buffer - s32Temp) = (((u32Red * u32Intensity2)) & 0xf800) |
             (((u32Green * u32Intensity2) >> 8) & 0x07e0) |
             ((u32Blue * u32Intensity2) >> 8);

  *(pu16Buffer) = u16Color;

  *(pu16Buffer + s32Temp) = (((u32Red * u32Intensity1)) & 0xf800) |
             (((u32Green * u32Intensity1) >> 8) & 0x07e0) |
             ((u32Blue * u32Intensity1) >> 8);

  pu16Buffer += s32XStep;
  s32XDest--;
  s32XCounter += s32Step;

  if (s32XCounter >= 0x100)
  {
     pu16Buffer += s32Temp;
     s32XCounter -= 0x100;
  }

}
}

–>Neil-------------------------------------------------------------------------------
Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 “It tastes like it came off the back porch.” - Me

SDL itself is not meant to provide such things as graphic primitives; meant as a
basic interface library, no more. There are already SEVERAL add-on libraries for
SDL that provide graphics primitives support for SDL, conveniently enough…

SDL_Draw: http://sdl-draw.sourceforge.net/
SDL_gfx: http://www.ferzkopp.net/Software/SDL_gfx-2.0/
SDSL_prim: http://www.tempestgames.com/ryan/

Neil Bradley wrote:> Is there any chance or interest in having line drawing in the SDL library?

I’d be happy to SDL-ize it and submit it to the library. Obviously, I’d
have to make 8bpp, 24bpp, and 32bpp versions of the routines as well as
include my translucency and “normal” linedraws and of course clipping.

I tried WU antialiasing but it really looks bad. One side of the line
looks great, the other is just as stairstepped as the original
nonantialiased line. Yuck.

Anyway, this routine is only about 15% slower than a regular single pixel
draw, and it also includes gamma correction. The lines look really, really
sharp! Here is a segment when it’s an X major stepping, and I think I’ve
pretty much optimized it to the point it can be optimized, but I’d love
to hear any ideas from other experts in graphics. The only thing I’m
thinking now is that the 16bpp accesses kill the Pentium pipeline…

–>Neil


Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 “It tastes like it came off the back porch.” - Me


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

Is there any chance or interest in having line drawing in the SDL library?
I’d be happy to SDL-ize it and submit it to the library. Obviously, I’d
have to make 8bpp, 24bpp, and 32bpp versions of the routines as well as
include my translucency and “normal” linedraws and of course clipping.

Feel free to put together a little add-on library that people can use,
and add it to the SDL website.

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment