Sign in to follow this  

Masking problem

This topic is 4227 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Guys, I have been having troubles with masks. This is the history: I setup two quads, one had a texture applied to it, and the second one had a black/white mask applied to it. That worked fine. Now i have modified the code so that the first quad does not have a texture applied, and i have given the quad a color with glcolor3f(1.0f,0.0f,0.0f). Now for some reason I get a blank screen instead of say red showing through the white part of the mask. The weird thing is if I leave IN the line :
	glBindTexture(GL_TEXTURE_2D, texture[0]); 
but dont apply the texture with glTexCoord2f, it works, ie:
	glBindTexture(GL_TEXTURE_2D, texture[0]);							
	glBegin(GL_QUADS);// Draw A Quad
	glColor3f(1.0f,0.0f,0.0f);
	glVertex3f(-1.0f, 1.0f, 0.0f);		// Top Left
	glVertex3f( 1.0f, 1.0f, 0.0f);		// Top Right
	glVertex3f( 1.0f,-1.0f, 0.0f);		// Bottom Right
	glVertex3f(-1.0f,-1.0f, 0.0f);		// Bottom Left
	glEnd();	

I dont see why I just cant have: glBegin(GL_QUADS);// Draw A Quad glColor3f(1.0f,0.0f,0.0f); glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); The full code is :
int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer
	glLoadIdentity();									// Reset The Current Modelview Matrix
	glTranslatef(0.0f,0.0f,-5.0f);	
	
	glBindTexture(GL_TEXTURE_2D, texture[0]);							
	glBegin(GL_QUADS);// Draw A Quad
	glColor3f(0.0f,1.0f,0.0f);
	glVertex3f(-1.0f, 1.0f, 0.0f);		// Top Left
	glVertex3f( 1.0f, 1.0f, 0.0f);		// Top Right
	glVertex3f( 1.0f,-1.0f, 0.0f);		// Bottom Right
	glVertex3f(-1.0f,-1.0f, 0.0f);		// Bottom Left
	glEnd();		

	glEnable(GL_BLEND);								// Enable Blending
	glDisable(GL_DEPTH_TEST);						// Disable Depth Testing
	glBlendFunc(GL_DST_COLOR,GL_ZERO);				// Blend Screen Color With Zero (Black)

	glBindTexture(GL_TEXTURE_2D, texture[1]);							// Move Right 3 Units
	glBegin(GL_QUADS);													// Draw A Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.0f, 2.0f, 0.0f);		// Top Left
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.0f, 2.0f, 0.0f);		// Top Right
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.0f,-2.0f, 0.0f);		// Bottom Right
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.0f,-2.0f, 0.0f);		// Bottom Left
	glEnd();	

	glDisable(GL_BLEND);

	return TRUE;										// Keep Going
}
Cheers -Al

Share this post


Link to post
Share on other sites
have you tried to disable the GL_TEXTURE_2D while rendering the red quad?
(you also need to disable the lighting or you use glColorMaterial...i dont know if you use lighting...

Share this post


Link to post
Share on other sites

This topic is 4227 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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