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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
void init_display_princ(){
int i,j;
GLUquadricObj *t;
t=gluNewQuadric();
gluQuadricNormals(t, GLU_FLAT);
gluQuadricTexture(t, GL_TRUE);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
liste_labyrinthe=glGenLists(1);
glNewList(liste_labyrinthe,GL_COMPILE);
for (i=0; i<=dim_n-1;i++)
{
for (j=0; j<=dim_m-1;j++)
{
glPushMatrix();
glTranslatef(i,j,0);
/*le sol*/
glInterleavedArrays (GL_T2F_V3F, 0, &inter_sol);
glBindTexture(GL_TEXTURE_2D, texName[0]);
glNormal3i(0,0,1);
glDrawElements (GL_QUADS,4,GL_UNSIGNED_BYTE,indices_sol );
/*le plafond*/
glInterleavedArrays (GL_T2F_N3F_V3F, 0, &inter_plafond);
glBindTexture(GL_TEXTURE_2D, texName[2]);
glDrawElements (GL_TRIANGLE_FAN,8,GL_UNSIGNED_BYTE,indices_plafond);
/*les poutres*/
glVertexPointer(3,GL_FLOAT,0,poutres);
glBindTexture(GL_TEXTURE_2D, texName[3]);
glNormal3f(0.0f,0.0f,-1.0f);
glDrawElements (GL_QUAD_STRIP, 10, GL_UNSIGNED_BYTE, indices_poutres);
if(univers[i][j].mur==1)
{
/*les murs*/
glInterleavedArrays (GL_T2F_V3F, 0, &inter_mur);
glBindTexture(GL_TEXTURE_2D, texName[1]);/*Pose des murs*/
glNormal3i(-1,0,0);
glDrawElements (GL_QUADS,4,GL_UNSIGNED_BYTE,face_indices );
glNormal3i(0,1,0);
glDrawElements (GL_QUADS,4,GL_UNSIGNED_BYTE,gauche_indices );
glNormal3i(1,0,0);
glDrawElements (GL_QUADS,4,GL_UNSIGNED_BYTE,droite_indices );
glNormal3i(0,-1,0);
glDrawElements (GL_QUADS,4,GL_UNSIGNED_BYTE,derriere_indices );
glBindTexture(GL_TEXTURE_2D, texName[3]);
glPushMatrix();
glTranslatef(0,0,0);
gluCylinder(t,0.062,0.062,2,6,8);
glPopMatrix();
glPushMatrix();
glTranslatef(1,0,0);
gluCylinder(t,0.062,0.062,2,6,8);
glPopMatrix();
glPushMatrix();
glTranslatef(0,1,0);
gluCylinder(t,0.062,0.062,2,6,8);
glPopMatrix();
glPushMatrix();
glTranslatef(1,1,0);
gluCylinder(t,0.062,0.062,2,6,8);
glPopMatrix();
}
glPopMatrix();
}}
glEndList();
gluDeleteQuadric(t);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
} |
Partager