PDA

View Full Version : Can't get blending to work correctly



wwuster
01-21-2010, 08:36 AM
I'm trying to draw this circle:
http://www.hindbrain.net/icon2.png

on top of an opengl scene. The file (icon2.png) is 256x256 rgba. I'm having trouble to get it to draw correctly. I've tried all sorts of combinations of glBlendFunc() and glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, ...) but can't get it to work correctly. Most often the circle is too dark (almost black) or the area outside the circle (the entire square) is shown.

Could someone tell me what the right combination of settings to use? I've tried settings from the NeHe tutorial to start with. I'm drawing this in orthogonal mode.

thanks,
William

ZbuffeR
01-21-2010, 08:43 AM
enable blending
disable lighting
glColor3f(1,1,1); //
use default glBlendFunc ( which is conveniently GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
use default texture mode modulation

draw circle

-> should work.

wwuster
01-21-2010, 09:34 AM
Here's what I've tried now. The circle is still too dark. The glColor3f() call causes the circle to to be colored strangely.

glEnable( GL_TEXTURE_2D );
glEnable( GL_BLEND );
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
glDisable(GL_LIGHTING);
//glColor3f(1,1,1);

The result rendering is here:
http://www.hindbrain.net/result.png

William

ZbuffeR
01-21-2010, 11:56 AM
remove this line : glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);

can you post your whole code related to texturing ?