Hi everyone,
I’m trying to draw semi-transparent antialiased polygons. Here’s a code snippet that tries to test this out:
(where w and h are the window dimensions in pixels)
glClearColor( 1, 1, 1, 0 );
glEnable( GL_BLEND );
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, w, 0, h, -1.0l, 1.0l);
glMatrixMode(GL_MODELVIEW);
glClear( GL_COLOR_BUFFER_BIT );
glEnable( GL_POLYGON_SMOOTH );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glLoadIdentity();
glRotatef( -10, 0, 0, 1 );
glColor4f( 0, 0, 1, 1 );
glBegin( GL_POLYGON );
glVertex2f( 140, 300 );
glVertex2f( 160, 300 );
glVertex2f( 160, 50 );
glVertex2f( 140, 50 );
glEnd();
glColor4f( 1, 0, 0, 0.5 );
glBegin( GL_POLYGON );
glVertex2f( 100, 100 );
glVertex2f( 200, 100 );
glVertex2f( 200, 200 );
glVertex2f( 100, 200 );
glEnd();
And here’s the result:
www.leadtogold.com/temp/cracks.jpg
Everything is exactly how I want it, in terms of the transparency and antialiasing effects, except for those faint cracks running between triangles! They obviously have the same vertices, so I know that’s not the problem, and I can make the cracks go away if I either disable antialiasing or use a different blending mode that kills my transparency effect. I’d really like to have them both, though.
Any suggestions would be very much appreciated!