glBindTexture( GL_TEXTURE_2D, m_texture[1] );
if( m_bBlend )
{
glEnable( GL_BLEND );
glDisable( GL_DEPTH_TEST );
}
glBegin( (m_bWireFrame)? GL_LINE_LOOP : GL_QUADS );
glNormal3f( 0.0f, 0.0f, 1.0f );
glColor4f( 1.0f, 1.0f, 1.0f, 0.5f );
glTexCoord2f( 0, 0 ); glVertex3f( -60, -10, -95);
glTexCoord2f( 10, 0 ); glVertex3f( 60, -10, -95);
glTexCoord2f( 10, 1 ); glVertex3f( 60, 10, -95);
glTexCoord2f( 0, 1 ); glVertex3f( -60, 10, -95);
glEnd();
if( m_bBlend )
{
glEnable( GL_DEPTH_TEST );
glDisable( GL_BLEND );
}
What is wrong with what i have done?
Alpha blending with opengl
I''m just trying to draw a quad that is semi-transparent over what has already been drawn. I call glBlendFunc( GL_SRC_ALPHA, GL_ONE ); in my gl init code and when i go to draw the quad that i want to blend with what''s on the screen i call glEnable( GL_BLEND ) and after i''m done drawing that quad i call glDisable( GL_BLEND ). This kind of works. The quad blends with what''s there but very poorly. I expected to be able to control the alpha blending with the fourth parameter in glColor4f() which I call like so:
try GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA. Also, make sure the transparent polygon is drawn AFTER everything else. If you have multiple transparent polygons, you have to sort them and draw them furthest to closest.
An alternative to drawing the transparent polygon last is surrounding the drawing of transparent polygons with a disable/enable of depth WRITING (make sure GL_DEPTH_TEST is still enabled though). Disabling is done via glDepthMask(GL_FALSE), and enabling with GL_TRUE.
no it isn t as far as i know you can set specific alpha values for each vertex that way
would be interesting if you could do lighning that way as well
black color for the shadows vertices and white colors for the enlightened*spelling?* vertices
would be interesting if you could do lighning that way as well
black color for the shadows vertices and white colors for the enlightened*spelling?* vertices
u have normal + color!
with lioghting enabled color is ignored (unless u use color_material) so first disable lighting + then try it
http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
with lioghting enabled color is ignored (unless u use color_material) so first disable lighting + then try it
http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
zedzeek is right. With lighting enabled, the alpha component is taken to be that of the diffuse material color, and glColor is ignored. The material color can be set by using glMaterial, or made to track the current color by using glColorMaterial.
http://users.ox.ac.uk/~univ1234
http://users.ox.ac.uk/~univ1234
okay, turning off the lighting workd wonderfully, now is there a way to get the same result with lighting enabled?
yes there is BUT u dont want to do it i beieve
use color_material
why dont u want to do it?
cause youre draw one quad over the screen ie 4 vertices
what u shoudl do is turnoff lighting draw quad + then turn lighting back on.
http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
use color_material
why dont u want to do it?
cause youre draw one quad over the screen ie 4 vertices
what u shoudl do is turnoff lighting draw quad + then turn lighting back on.
http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement