Masking

Started by
0 comments, last by mindemc 20 years, 6 months ago
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();
Advertisement
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]
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/

This topic is closed to new replies.

Advertisement