Sign in to follow this  
EricmBrown

OpenGL Opengl Blending bleeding/artifacting

Recommended Posts

I'm using the following method to draw my mouse, a bitmap textured GL_QUAD. The mouse alpha is a black and white copy used to "fake" the alpha channel (since bitmaps don't support alpha channels). It works great except that I'm getting some artifacting/bleeding of some of the pixels which looks undesireable. Any ideas whats causing it? Thanks.
		glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glDisable(GL_DEPTH_TEST);
	
	glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
	glBlendFunc(GL_DST_COLOR,GL_ZERO);

	
	setTexture(mouseAlpha);
	glBegin(GL_QUADS);
		glTexCoord2f(0.0,0.0);glVertex2f(loc.x,loc.y);
		glTexCoord2f(1.0,0.0);glVertex2f(loc.x+width,loc.y);
		glTexCoord2f(1.0,1.0);glVertex2f(loc.x+width,loc.y+height);
		glTexCoord2f(0.0,1.0);glVertex2f(loc.x,loc.y+height);
	glEnd();


	glBlendFunc(GL_ONE,GL_ONE);
	setTexture(mouseCurrent);
	glBegin(GL_QUADS);
		glTexCoord2f(0.0,0.0);glVertex2f(loc.x,loc.y);
		glTexCoord2f(1.0,0.0);glVertex2f(loc.x+width,loc.y);
		glTexCoord2f(1.0,1.0);glVertex2f(loc.x+width,loc.y+height);
		glTexCoord2f(0.0,1.0);glVertex2f(loc.x,loc.y+height);
	glEnd();

	glDisable(GL_TEXTURE_2D);
	glEnable(GL_DEPTH_TEST);
	glDisable(GL_BLEND);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this