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
| Star::Star() {
squeletteX={0.0, 0.4, 1.0, 0.6, 0.8, 0.0, -1.0, -0.4, -1.0, -0.2, 0.0};
squeletteY={1.0, 0.4, 0.4, 0.0, -0.8, -0.4, -1.0, 0.0, 0.4, 0.4, 1.0};
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glMatrixMode(GL_MODELVIEW);
}
void Star::affiche() {
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode(GL_MODELVIEW);
int couleur[2][3]={{137, 169, 231}, {70, 131, 83}};
int flagCouleur=0;
int indexCouleur=0;
double z1=0.1, z2=-0.1;
glBegin(GL_QUADS);
for(int i=0;i<10;i++)
{
flagCouleur++;
indexCouleur=flagCouleur%2;
//glColor3ub(couleur[indexCouleur][0], couleur[indexCouleur][1], couleur[indexCouleur][0]);
glVertex3d(squeletteX[i] ,squeletteY[i] , z1);
glVertex3d(squeletteX[i+1], squeletteY[i+1], z1);
glVertex3d(squeletteX[i+1], squeletteY[i+1], z2);
glVertex3d(squeletteX[i] ,squeletteY[i] , z2);
}
glEnd();
glRotated(45,0,0,1);
glRotated(45,0,0,1);
glRotated(45,1,0,0);
glFlush();
SDL_GL_SwapBuffers();
} |
Partager