I want to draw a box with GL_LINES, connect 4 lines to form a box
Then draw a line that passes through the box created above.
When the line is around the area of the box, line should not be visible for the area of box
How can I achieve this, I am not understanding alpha blending correctly.
The code is below
//I can draw a black occlusion zone around the lined box, but it is not preferred so commented here
/*
glPushMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glColor3f(0.20, 0.20, 0.60);
glBegin(GL_POLYGON);
glVertex2f(-62, 62);
glVertex2f( 62, 62);
glVertex2f( 62, -2);
glVertex2f(-62, -2);
glEnd();
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
glPopMatrix();
*/
// Here I am drawing the lined Box before drawing the lines that passes through it
glPushMatrix();
glLineWidth(2);
glColor3f(1.0, 1.0, 0.95);
glBegin(GL_LINES);
glVertex2f(-60, 0);
glVertex2f(60, 0);
glVertex2f(-60, 60);
glVertex2f(60, 60);
glVertex2f(60, 60);
glVertex2f(60, 0);
glVertex2f(-60, 0);
glVertex2f(-60, 60);
glEnd();
glPopMatrix();
// Here I am drawing a white line with width 2, this should not be visible when it goes over or under the
// lined box area. I can draw the occlusion zone and change the order to do it. But I would like to know
// how we can change this using alpha blending. The order has to be same, the background color I did is orange.
glColor3f(1.0, 1.0, 1.0);
glPushMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glLineWidth(2);
glBegin(GL_LINES);
glVertex2f(-120, 30);
glVertex2f(120.0, 30.0);
glEnd();
glDisable(GL_BLEND);
glPopMatrix();
How can I do this using blend function. Lines should be visible all other area except the lined box area. If I draw
the box occlusion zone, this will not match with the background image (which is a video, color is not the same always).
Please help me.
ntpkd