sathish v
sathish v

Reputation: 559

OpenGL: How to draw a triangle or polygon smoothly

I'm drawing a triangle using polygonmode as below:

drawScene(void)
{
    glPopMatrix();
    glEnable(GL_POLYGON_SMOOTH);
    glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glShadeModel(GL_POLYGON_SMOOTH);

    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    glBegin(GL_POLYGON);
        glVertex3f(x,y,z);
        glVertex3f(x1,y1,z1);
        glVertex3f(x2,y2,z2);
    glEnd();
    glPopMatrix();
}

Vertices (x, y, z, x1, y1, z1, x2, y2, z2) are calculating using sin() and cos() and im passing into drawScene() method. Triangle is rotated based on the sin() and cos() values. My problem is, triangle is not smooth when it is drawn. That is, outer part of the triangle is not have a smooth line. In the above code instead of GL_FILL if I use GL_LINE triangle looks smooth. But, I need a filled triangle.

Upvotes: 1

Views: 6708

Answers (1)

Camilo Martin
Camilo Martin

Reputation: 37918

Depending on the graphics card, anti-aliasing may not be avaliable, may be disabled, or may be application-controlled.

For example, take a look at this configuration page from a graphics card:

NVidia CP

So, in this case any 3D application will be aliased, since the user chooses to, and you can't/shouldn't go around that choice. Check your graphics card control panel/settings to see if it has such an option (it may not support anti-aliasing depending on its age).

Furthermore, please take some time writing a descriptive, accurate title for your questions or nobody here will pay you much attention.

Upvotes: 1

Related Questions