Login  Register

Antialiased polygons in JOGL 2.0 rc3

Posted by Archie on Sep 26, 2011; 4:03pm
URL: https://forum.jogamp.org/Antialiased-polygons-in-JOGL-2-0-rc3-tp3369689.html

Hey guys,  

I'm having some serious trouble trying to get antialiased polygons working with JOGL 2.0 rc3.  Essentially what I am trying to do is take the nice little demonstration file that is on the leolol website and just add antialiasing to the it's polygon or QUADS drawing.  I have followed the advice of a few OPENGL tutorials out there but none of them seem to work.  If anyone can share some insights that would be great.  Along with the bits of the program that are of interest I have also included a full link to the source code here: http://pastebin.com/msdmfWTV

I'm on windows 7 with a geforce 8800gts.

Here is what I have in the init method:

    public void init(GLAutoDrawable gLDrawable) {
        GL2 gl = gLDrawable.getGL().getGL2();
        gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
       
        //gl.glBlendFunc (GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);  // This makes everything black!?
        gl.glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
       
        // enable polygon antialiasing
        gl.glClear (GL.GL_COLOR_BUFFER_BIT);
        gl.glEnable (GL2.GL_BLEND);
        gl.glEnable (GL2.GL_POLYGON_SMOOTH);
        gl.glDisable (GL.GL_DEPTH_TEST);
        gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST);
       
        gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
        ((Component) gLDrawable).addKeyListener(this);
    }

and here is the display method:

    public void display(GLAutoDrawable gLDrawable) {
        final GL2 gl = gLDrawable.getGL().getGL2();
       
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);
        //gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
       
        gl.glLoadIdentity();
        gl.glTranslatef(0.0f, 0.0f, -5.0f);
 
        // rotate on the three axis
        gl.glRotatef(rotateT, 1.0f, 0.0f, 0.0f);
        gl.glRotatef(rotateT, 0.0f, 1.0f, 0.0f);
        gl.glRotatef(rotateT, 0.0f, 0.0f, 1.0f);
 
        // Draw A Quad
        gl.glBegin(GL2.GL_QUADS);          
            gl.glColor4f(0.0f, 1.0f, 1.0f, 1.0f);   // set the color of the quad
            gl.glVertex3f(-1.0f, 1.0f, 0.0f);      // Top Left
            gl.glVertex3f( 1.0f, 1.0f, 0.0f);       // Top Right
            gl.glVertex3f( 1.0f,-1.0f, 0.0f);      // Bottom Right
            gl.glVertex3f(-1.0f,-1.0f, 0.0f);     // Bottom Left
        // Done Drawing The Quad
        gl.glEnd();                                                    
 
        // increasing rotation for the next iteration                                
        rotateT += 0.2f;
    }

Thanks for your time!