Hello everybody
I'm creating a solar system. All work except one thing : the light:
I don't succeed to put a light in my solar system. I use gluQuadric to put a texture on my spheres and I don't understand why there aren't lights whereas I put it in my code... And it's urgent, it's the only one thing that doesn't work and I have to send my project on Monday

Here a part of my code :
int LightPos[4] = {1,20,20,0};
int MatSpec [4] = {1,1,1,1};
....
void init(void){
GLfloat couleurAP[]={0.5,0.5,0.5,1.0}; /* couleur de fond */
// Paramètres d'eclairage /
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glLightfv(GL_LIGHT0,GL_DIFFUSE,L0dif);
glLightfv(GL_LIGHT0,GL_SPECULAR,L0dif);
glLightfv(GL_LIGHT1,GL_DIFFUSE,L1dif);
glLightfv(GL_LIGHT1,GL_SPECULAR,L1dif);
glEnable(GL_LIGHTING);
*/
...
glShadeModel (GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glGenTextures(20,texName);
creation_texture("textures/terre.jpg",texture_terre);
glTexImage2D(GL_TEXTURE_2D,0,3,
LI,LH,0,GL_RGB,
GL_UNSIGNED_BYTE,
&texture_terre);
creation_texture("textures/lune.jpg",texture_lune);
glTexImage2D(GL_TEXTURE_2D,0,3,
LI,LH,0,GL_RGB,
GL_UNSIGNED_BYTE,
&texture_lune );
...
glEnable(GL_TEXTURE_2D);
}
//----------------------------------------------------
void display(void)
{
GLUquadricObj * qobj;
int i;
qobj = gluNewQuadric();
glMaterialiv(GL_FRONT_AND_BACK,GL_SPECULAR,MatSpec);
glMateriali(GL_FRONT_AND_BACK,GL_SHININESS,100);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt (0.0, hauteur, distance, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glRotatef(xvu,yvu,1.0,0.0);
glLightiv(GL_LIGHT0,GL_POSITION,LightPos);
//
....
//-----Soleil---------------
glBindTexture(GL_TEXTURE_2D,texName[10]);
glPushMatrix();
gluQuadricDrawStyle(qobj,GLU_FILL); //soleil avec une equation quadrique
gluQuadricNormals(qobj,GLU_SMOOTH);
gluQuadricTexture(qobj,GL_TRUE);
gluSphere(qobj,1.0,20.0,20.0);
glPopMatrix();
glPopMatrix();
//--------Terre-------
glBindTexture(GL_TEXTURE_2D,texName[0]);
glPushMatrix();
glRotatef (year, 0.0, 1.0, 0.0);
glTranslatef (6.0, 0.0, 0.0);
glRotatef (-year, 0.0, 1.0, 0.0);
glRotatef (year*3, 0.3907, 0.92705, 0.0);
gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
gluQuadricTexture(qobj,GL_TRUE);
gluSphere(qobj,0.2,10.0,8.0);
glPopMatrix();
....
glutPostRedisplay();
glutSwapBuffers();
}
/*-----------------------------------------------------------------------*/
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 400.0);
glMatrixMode(GL_MODELVIEW);
;
}
/*----------------------------------------------------------------------*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (800, 800);
glutInitWindowPosition (100, 100);
glutCreateWindow ("Système solaire");
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(souris);
glutMotionFunc(mouvSouris);
glutMainLoop();
return 0;
}
Thank you for your patience

Ludo
[edited by - ludo on June 20, 2003 9:39:10 AM]