🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Mask & colour

Started by
0 comments, last by daviddiligent 16 years, 2 months ago
When I am trying to set my sprite with different colour, it will also display a coloured background, which shouldnt be there. e.g. if i have a plane and its mask. If i don't set any colour. The plane will be drawn on the screen and other parts will be transparent. but if I want the plane to appear to be red, I use glColor3f(1.0f,0.0f,0.0f). Then the plane looks red, but then there will be a red square around it. How will I get rid of the coloured background? Any suggestions? Here is my code

	glColor3f(1.0f,0.0f,0.0f);
	glEnable(GL_TEXTURE_2D);
        //draw mask first, then draw real textures.
	glEnable(GL_BLEND);
	glBlendFunc(GL_DST_COLOR,GL_ZERO);					// Set Blending Mask Cancels Screen Objects
	glBindTexture(GL_TEXTURE_2D, textureMask);				// Bind Our Texture (Mask Texture)
	glBegin(GL_QUADS);									// Begin Drawing Triangles
		glTexCoord2f(1.0f,1.0f); glVertex3f( width/2,-height/2, 0.0f);			
		glTexCoord2f(0.0f,1.0f); glVertex3f(-width/2,-height/2, 0.0f);	            
		glTexCoord2f(0.0f,0.0f); glVertex3f(-width/2, height/2, 0.0f);				
		glTexCoord2f(1.0f,0.0f); glVertex3f( width/2, height/2, 0.0f);	            
	glEnd();												
	glBlendFunc(GL_ONE, GL_ONE);							// Object Only Maps To Mask
	glBindTexture(GL_TEXTURE_2D, texture); .
	glBegin(GL_QUADS);														        
		glTexCoord2f(1.0f,1.0f); glVertex3f( width/2,-height/2, 0.0f);				
		glTexCoord2f(0.0f,1.0f); glVertex3f(-width/2,-height/2, 0.0f);	            
		glTexCoord2f(0.0f,0.0f); glVertex3f(-width/2, height/2, 0.0f);				
		glTexCoord2f(1.0f,0.0f); glVertex3f( width/2, height/2, 0.0f);	            
	glEnd();		
	glDisable(GL_BLEND);
	glDisable(GL_TEXTURE_2D);



[Edited by - daviddiligent on May 1, 2008 6:55:29 AM]
/*----------------------------------------------------------------------------------------------------------------------------------*/Enthusiastic and wild about game development. Any opportunity would get me sink into any fantastic game-revolution era.
Advertisement
OK. Never mind. I figured it out myself :) :)
/*----------------------------------------------------------------------------------------------------------------------------------*/Enthusiastic and wild about game development. Any opportunity would get me sink into any fantastic game-revolution era.

This topic is closed to new replies.

Advertisement