Fichier source : Benzene.cpp
Modules utilitaires
/* Scene dessinee */
static void mySolidCylinder(double h,double r,int n,int m) {
glPushMatrix();
glRotatef(90.0F,1.0F,0.0F,0.0F);
glTranslatef(0.0F,0.0F,-h/2);
GLUquadricObj *qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj,GLU_FILL);
gluCylinder(qobj,r,r,h,n,m);
gluDeleteQuadric(qobj);
glPopMatrix();
}
static void motif(int objet) {
glPushMatrix();
glTranslatef(2.0F,0.0F,0.0F);
glutSolidSphere(0.5,36,36);
glPushMatrix();
glRotatef(30.0,0.0F,0.0F,1.0F);
glTranslatef(0.0F,1.0F,0.0F);
switch (objet) {
case 2 :
mySolidCylinder(2.0,0.15,20,20);
break;
case 1 :
glTranslatef(0.1F,0.0F,0.0F);
mySolidCylinder(2.0,0.05,20,20);
glTranslatef(-0.2F,0.0F,0.0F);
mySolidCylinder(2.0,0.05,20,20);
break;
case 0 :
mySolidCylinder(2.0,0.05,20,20);
break; }
glPopMatrix();
glTranslatef(0.6F,0.0F,0.0F);
glPushMatrix();
glRotatef(90.0,0.0F,0.0F,1.0F);
mySolidCylinder(1.2,0.05,20,20);
glPopMatrix();
glTranslatef(0.6F,0.0F,0.0F);
glutSolidSphere(0.25,36,36);
glPopMatrix();
}
static void scene(void) {
glPushMatrix();
for ( int i = 0 ; i < 6 ; i++ ) {
float angle = i*60.0F;
glPushMatrix();
glRotatef(angle,0.0F,0.0F,1.0F);
motif((objet) ? i%2 : 2);
glPopMatrix(); }
glPopMatrix();
}