Anti-Aliasing Programming

This is a discussion on Anti-Aliasing Programming within the C Programming forums, part of the General Programming Boards category; Hi everyone, I apologized if this has been answered before, but I searched for a pretty darn long time and ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    1

    Question Anti-Aliasing Programming

    Hi everyone,

    I apologized if this has been answered before, but I searched for a pretty darn long time and could find nothing.

    Anyways, like the topic says, I was wondering if there was a way to program code for anti-aliasing. What I am doing is making an attitude indicator gauge for a flight simulator cockpit and I made the background bitmap with the degrees and the lines but when it rotates, the lines are so jagged it just looks like crap. Is there a way to program so the lines are even a little bit smoother? The bottom few lines I tried painting another extra pixel of light gray underneath and it seems to help...barely. Here is an image of what I mean:
    http://img.photobucket.com/albums/v3...ou/dc10adi.jpg (The lines I am talking about are the small black ones on the light blue background) It's extremely worse once it's normal size, which needs to be used for the cockpit)

    Thank you very much for any help! And just to clarify, it's not just anti-aliasing settings for gaming. I know how to do that. Just not with programming. Thanks again!

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    The SDL_gfx library has anti-aliased lines, circles, polygons, you name it. You can get the source code for it, although I don't know how readable this would be. Or if you're using the SDL you could just use SDL_gfx directly.

    [edit] For OpenGL: http://post.doit.wisc.edu/library/te...ref/aliasc.htm

    Do you want to create an antialiased line function, or do you just want to use ready-existing functions to draw the line? [/edit]
    Last edited by dwks; 08-31-2006 at 04:35 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Very nice job on the attitude indicator. Looks very good.

    Anti-aliasing is not as simple as just drawing another line over the existing one. Actually what takes place is while the line is being drawn, pixels to the left and right or above and below the pixel in the line are being averaged and/or bilinear filtered together to form the final output pixel.

    You can either do a 4-way neighbor average or an 8-way neighbor average. The 4 way average looks ok, but begins to produce small star like patterns. 8-way is the best but requires 8 pixel loads ala 8 memory accesses. Not a big deal if it's in system memory but if it's in video memory, it's a very big deal.

    Anti-aliasing is supported natively on OpenGL and DirectX through drivers which tell the card to use anti-aliasing. Anti-aliasing is usually supported both at the primitive level and at the screen level or FSAA.

    Any algo you use is going to be slower than hardware.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Anti aliasing
    By arjunajay in forum Windows Programming
    Replies: 7
    Last Post: 08-15-2006, 08:24 PM
  2. Best Anti Virus Software...?
    By gardenair in forum Tech Board
    Replies: 4
    Last Post: 05-01-2003, 11:17 PM
  3. anti virus algorithm
    By sadat in forum C Programming
    Replies: 3
    Last Post: 06-03-2002, 09:58 AM
  4. help me in developing a good anti virus program
    By sadat in forum C++ Programming
    Replies: 3
    Last Post: 04-04-2002, 01:09 PM
  5. anti aliasing
    By muttski in forum Game Programming
    Replies: 2
    Last Post: 03-16-2002, 05:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21