Masking problem

Started by
0 comments, last by WarMuuh 17 years, 11 months ago
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
Advertisement
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...

This topic is closed to new replies.

Advertisement