Results 1 to 3 of 3

Thread: Polygon Antialiasing question

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2003
    Location
    Vancouver, BC, Canada
    Posts
    18

    Polygon Antialiasing question

    Hello,

    The following is my polygon antialiasing code:

    glEnable(GL_POLYGON_SMOOTH);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glPushMatrix();
    glBegin(GL_POLYGON)
    glVertex3f(-1.0f ,0.0f, -1.0f);
    glVertex3f(1.0f, 0.0f, -1.0f);
    glVertex3f(1.0f, 0.0f, 1.0f);
    glVertex3f(-1.0f, 0.0f, 1.0f);
    glEnd()
    glPopMatrix();

    glDisable(GL_BLEND);
    glDisable(GL_POLYGON_SMOOTH);

    However, The diagonal line of the polygon is partly the background color. Can anyone tell me what's the problem here?

    It seems like OpenGL cut the polygon into triangles and anti-alias each triangle instead of the whole polygon.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    477

    Re: Polygon Antialiasing question

    Hi,

    I use this, and it works :
    // Blending params
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

    // Anti-Aliasing params
    glEnable(GL_LINE_SMOOTH);

    // AA ==> ON
    glEnable(GL_LINE_SMOOTH);

    glLineWidth(55.0f);
    glBegin(GL_LINES);
    glVertex3f(-18.0f,-6.0f, 0.0f);
    glVertex3f(8.0f,6.0f,0.0f);
    glEnd();

    Yes it's for the lines but should work with polygons

  3. #3
    Senior Member Regular Contributor
    Join Date
    Sep 2003
    Location
    Bucharest, Romania
    Posts
    143

    Re: Polygon Antialiasing question

    Hi,
    There was a topic on this matter about a month ago, and the conclusion is here:
    - to antialias polygons you have to draw on black transparent background (even when drawing with black);
    - use the blending function GL_SRC_ALPHA_SATURATE, GL_ONE (of course, first enable blending and polygon smoothing);
    - draw your geometry from front (first) to back (last), with depth buffering disabled;
    - to get the desired background colour, draw one last quad over the result;
    This might not work properly on cards that are not professional ones. It still seems to work on GeForce4s, but not on Radeons. Basically, you need to have a card / driver that makes use of the computed coverage. Anyway, you should request (and hopefully get) an accelerated rendering context, the generic implementation eihter is dead slow or doesnt' work at all.
    The lines between the triangles (when using the line smoothing blending function) are there because the triangles are blended one at a time, and the blending on the inner edges is done not with the background, but with the already blended edge.
    Hope I was clear enough.

Similar Threads

  1. Polygon antialiasing
    By jamievicary in forum OpenGL: Windows
    Replies: 4
    Last Post: 08-18-2008, 07:43 AM
  2. Polygon Antialiasing
    By MereMouse in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 08-10-2005, 10:27 AM
  3. Polygon antialiasing.
    By 9ine in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-15-2004, 03:37 PM
  4. Polygon antialiasing not working
    By in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 12-29-2003, 12:38 PM
  5. Polygon Antialiasing?
    By in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 06-29-2001, 08:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean