Both of you thank you very much for answering.
By using UnprojectPoint some how I managed to draw the quad on the screen.
My code for UnprojectPoint
Vector3f getOGLPosition(int x, int y)
{
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
GLfloat winX, winY, winZ;
GLdouble posX, posY, posZ;
glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
glGetDoublev( GL_PROJECTION_MATRIX, projection );
glGetIntegerv( GL_VIEWPORT, viewport );
winX = (float)x;
winY = (float)viewport[3] - (float)y;
glReadPixels( x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
return Vector3f(posX, posY, posZ);
}
And when drawing
Vector3f leftBottom = getOGLPosition(m_Left, m_Bottom);
Vector3f rightBottom = getOGLPosition(m_Right, m_Bottom);
Vector3f rightTop = getOGLPosition(m_Right, m_Top);
Vector3f leftTop = getOGLPosition(m_Left, m_Top);
glPushMatrix();
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 2);
glBegin(GL_QUADS);
glTexCoord2f (0.0, 0.0);
glVertex3f (leftBottom.x, leftBottom.y, leftBottom.z +1);
glTexCoord2f (1.0, 0.0);
glVertex3f (rightBottom.x, rightBottom.y, rightBottom.z +1);
glTexCoord2f (1.0, 1.0);
glVertex3f (rightTop.x, rightTop.y, rightTop.z +1);
glTexCoord2f (0.0, 1.0);
glVertex3f (leftTop.x, leftTop.y, leftTop.z +1);
glEnd();
glDisable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glPopMatrix();
The problem I face now is texturing.
I have printed the values of those 4 corners of quad and they are,
(-543, 650, -5917)
(202, 658, -5622)
(-13 56, -68)
(108, -88, -5434)
So texturing is extremely bad.
Kindly advice me if you know any other way of doing this?
Thank you