Hi there,
I want to draw a rect occupied all the client area. so i do the following, but it cannt work.
GLdouble projection[16], modelview[16];
GLint viewport[4];
GLdouble x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4;
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetIntegerv(GL_VIEWPORT, viewport);
GLfloat wndX,wndY, wndZ;
wndX = g_iWindowWidth;
wndY= viewport[3] - 0;
glReadBuffer(GL_BACK);
glReadPixels(wndX,wndY,1,1,GL_DEPTH_COMPONENT ,GL_INT, &wndZ);
gluUnProject(wndX, wndY, wndZ, modelview, projection, viewport, &x1, &y1, &z1);
wndX = 0;
wndY = viewport[3] - g_iWindowHeight;
glReadBuffer(GL_BACK);
glReadPixels(wndX,wndY,1,1,GL_DEPTH_COMPONENT ,GL_INT, &wndZ);
gluUnProject(wndX, wndY, wndZ, modelview, projection, viewport, &x2, &y2, &z2);
wndX = 0;
wndY = viewport[3] - g_iWindowHeight;
glReadBuffer(GL_BACK);
glReadPixels(wndX,wndY,1,1,GL_DEPTH_COMPONENT ,GL_INT, &wndZ);
gluUnProject(wndX, wndY, wndZ, modelview, projection, viewport, &x3, &y3, &z3);
wndX = g_iWindowWidth;
wndY = viewport[3] - 0;
glReadBuffer(GL_BACK);
glReadPixels(wndX,wndY,1,1,GL_DEPTH_COMPONENT ,GL_INT, &wndZ);
gluUnProject(wndX, wndY, wndZ, modelview, projection, viewport, &x4, &y4, &z4);
glBindTexture(GL_TEXTURE_2D, g_texture[0]);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 1.0f); glVertex3f(x1, y1, z1);
glTexCoord2f(0.0f, 1.0f); glVertex3f(x2, y2, z2);
glTexCoord2f(0.0f, 0.0f); glVertex3f(x3, y3, z3);
glTexCoord2f(1.0f, 0.0f); glVertex3f(x4, y4, z4);
glEnd();
i use glUnProject to convert the four corner pixel to the object coordinate, but i
dont know if this is right, can anybody help me? Thanks a lot!