1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
double modelview[16];
double projection[16];
GLint viewport[4];
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glGetIntegerv(GL_VIEWPORT,viewport);
VECTOR QuadSommet[4];
double x, y, z;
GLdouble winx, winy, winz;
gluProject(2.0, 2.0, 0.0, modelview, projection, viewport, &winx, &winy, &winz);
gluUnProject(winx, winy, winz, modelview, projection, viewport, &x, &y, &z);
QuadSommet[0].x = x; QuadSommet[0].y = y; QuadSommet[0].z = z;
gluProject(-2.0, 2.0, 0.0, modelview, projection, viewport, &winx, &winy, &winz);
gluUnProject(winx, winy, winz, modelview, projection, viewport, &x, &y, &z);
QuadSommet[1].x = x; QuadSommet[1].y = y; QuadSommet[1].z = z;
gluProject(-2.0,-2.0, 0.0, modelview, projection, viewport, &winx, &winy, &winz);
gluUnProject(winx, winy, winz, modelview, projection, viewport, &x, &y, &z);
QuadSommet[2].x = x; QuadSommet[2].y = y; QuadSommet[2].z = z;
gluProject(2.0,-2.0, 0.0, modelview, projection, viewport, &winx, &winy, &winz);
gluUnProject(winx, winy, winz, modelview, projection, viewport, &x, &y, &z);
QuadSommet[3].x = x; QuadSommet[3].y = y; QuadSommet[3].z = z;
glBindTexture(GL_TEXTURE_2D, texName[i]);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(QuadSommet[0].x, QuadSommet[0].y, QuadSommet[0].z);
glTexCoord2f(0.0, 1.0); glVertex3f(QuadSommet[1].x, QuadSommet[1].y, QuadSommet[1].z);
glTexCoord2f(1.0, 1.0); glVertex3f(QuadSommet[2].x, QuadSommet[2].y, QuadSommet[2].z);
glTexCoord2f(1.0, 0.0); glVertex3f(QuadSommet[3].x, QuadSommet[3].y, QuadSommet[3].z);
glEnd(); |