PDA

View Full Version : Blending

ltrain_riders
12-02-2002, 05:36 PM
If I use glColor4f( 0.5, 0.0, 0.5, 0.25 ); will I still need glBlendFunc(...); to create a transparent wall? I just want to create one section of wall in my project and not affect any others. Whats the best Constants to use inside glBlendFunc( )? This is what i'm trying to do:
glPushMatrix( );
glLoadIdentity( );
glColor4f( 0.5, 0.0, 0.5, 0.0 );
glBegin(GL_QUADS);
glNormal3f( 0.0, 1.0, 0.0 ); //top face
glVertex3f( -0.2, 0.5, -4.0 );
glVertex3f( -0.2, 0.5, -3.2 );
glVertex3f( 0, 0.5, -3.2 );
glVertex3f( 0, 0.5, -4.0 );

glNormal3f( -1.0, 0.0, 0.0 ); //left face
glVertex3f( -0.2, 0.5, -3.2 );
glVertex3f( -0.2, 0.5, -4.0 );
glVertex3f( -0.2, 0.1, -4.0 );
glVertex3f( -0.2, 0.1, -3.2 );

glNormal3f( 1.0, 0.0, 0.0 ); //right face
glVertex3f( 0.0, 0.5, -4.0 );
glVertex3f( 0.0, 0.5, -3.2 );
glVertex3f( 0.0, 0.1, -3.2 );
glVertex3f( 0.0, 0.1, -4.0 );
glEnd( );
glFlush( );
glPopMatrix( );

Bob
12-03-2002, 02:35 AM
Alpha by itself is just a fourth color component, and you must use blending if you want to treat it as a transparency factor. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) is a good function for transparency. However, for this function to work you must sort your triangles in back to front order. Meaning you should draw the triangle farthest from the viewpoint first, all the way to the nearest triangle.

[This message has been edited by Bob (edited 12-03-2002).]