Jump to content
  • Advertisement
Sign in to follow this  
freaky3

MASKING - Tutorial Lession 20

This topic is 4894 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! i tried the masking tutorial lession 20 in a programm created before. it occurs the problem that the part of he mask image which should be invisible is not completely invisible. the visible part of the mask is slightly yellow. also there are problems with other parts of my programm where i use blending. maybe it has something to do with the colorbuffer: if i clear the colorbuffer i see nothing of the background scene. if i don't clear it it's like i described above. thanks Daniel

Share this post


Link to post
Share on other sites
Advertisement
void drawMask(){
glClear(GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);

glBlendFunc(GL_DST_COLOR,GL_ZERO);

glTranslatef(0.0,0.0,-1.0);

glBindTexture(GL_TEXTURE_2D, textures[TEXTURE_MASK]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-20.1f, -10.1f, 0.0f); // Bottom Left
glTexCoord2f(1.0f, 0.0f); glVertex3f( 20.1f, -10.1f, 0.0f); // Bottom Right
glTexCoord2f(1.0f, 1.0f); glVertex3f( 20.1f, 10.1f, 0.0f); // Top Right
glTexCoord2f(0.0f, 1.0f); glVertex3f(-20.1f, 10.1f, 0.0f); // Top Left
glEnd();

glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D, textures[TEXTURE_IMAGE]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(-20.1f, -10.1f, 0.0f); // Bottom Left
glTexCoord2f(1.0f, 0.0f); glVertex3f( 20.1f, -10.1f, 0.0f); // Bottom Right
glTexCoord2f(1.0f, 1.0f); glVertex3f( 20.1f, 10.1f, 0.0f); // Top Right
glTexCoord2f(0.0f, 1.0f); glVertex3f(-20.1f, 10.1f, 0.0f); // Top Left
glEnd();



glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
}
________________________________________________________________________
//thats the routine that draws the mask. it is called from the following routinge:
void startDrawing() {

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
updateCam();
gluLookAt(camPos.x,camPos.y,camPos.z,
camPos.lookX,camPos.lookY,camPos.lookZ,
0.0,1.0,0.0);
glMatrixMode(GL_MODELVIEW);
initLight();
initFog();
drawScene();
drawExplosions();
glClearColor (0.3f, 0.3f, 0.3f, 0.8f);
showFrameRate();
drawGameStats();
-> drawMask();
glutSwapBuffers();
_fps = frameRate();
}

____________________________________
startDrawing is in the display function from the callback.


int init (void) {
/* Ignorieren des Keyrepeats */
glutIgnoreKeyRepeat(1);
/* z-Buffering aktivieren */
glEnable (GL_DEPTH_TEST);
/* Normalen nach Transformationen wieder auf die Einheitslaenge bringen */
glEnable (GL_NORMALIZE);
/* Polygonrueckseiten nicht anzeigen */
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);

glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

/* Alles in Ordnung? */
return (glGetError () == GL_NO_ERROR);
}
_______________________
thats the init routine.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!