Archived

This topic is now archived and is closed to further replies.

mindemc

Masking

Recommended Posts

mindemc    122
I am bitmap masking. My problem is I made a crosshair and can see all parts of crosshair bitmap. I use a white background bitmap with black as the actuall parts of the crosshair as the mask. I use a green crosshair with black background as the image that is masked. My code: //inside DrawGLScene // Crosshair glDisable(GL_DEPTH_TEST); glLoadIdentity(); glEnable(GL_BLEND); glTranslatef(0.0f,0.0f,-25.0f);//Translate into screen glBlendFunc(GL_DST_COLOR,GL_ZERO);//Blend screen color With zero (Black) glBindTexture(GL_TEXTURE_2D, texture[16]);//crosshair_mask.bmp glBegin(GL_QUADS); // Start Drawing A Textured Quad glTexCoord2d(1,1); glVertex2f(1,1); glTexCoord2d(1,0); glVertex2f(1,-1); glTexCoord2d(0,0); glVertex2f(-1,-1); glTexCoord2d(0,1); glVertex2f(-1,1); glEnd(); glBlendFunc(GL_ONE,GL_ONE); glBindTexture(GL_TEXTURE_2D,texture[1]);//crosshair.bmp glBegin(GL_QUADS); glTexCoord2d(1,1); glVertex2f(1,1); glTexCoord2d(1,0); glVertex2f(1,-1); glTexCoord2d(0,0); glVertex2f(-1,-1); glTexCoord2d(0,1); glVertex2f(-1,1); glEnd();

Share this post


Link to post
Share on other sites
Leyder Dylan    122
OK, first, it would be more logical to have white in the center and black in the border but anyway gonna try to fix that ...



You need to compute the mask color with the framebuffer with :

glBlendFunc(GL_ONE,GL_ZERO);


Now you can draw your mask :

// Draw your mask ...


Next, you need to modulate the mask and the crosshair so, here we go :

glBlendFunc(GL_DST_COLOR, GL_ZERO);


And the final step is to render your crosshair.

// Draw your crosshair ...


Take a look on my website, "Research" section, "Blending". You'll have my first article pertaining the blending. So, feel free to give me your impressions ...

Eh Vincoof, I was a good teacher ?



========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/

[edited by - Leyder Dylan on October 10, 2003 7:48:53 PM]

Share this post


Link to post
Share on other sites