reflection disappears

What is really happening when the reflections of the light in my object disappears. At start everything is really nice, but if I turn my object for a while, the reflections disappear…



Do you mean specular highlights? Could it be that you are rotating the light with the object? When you call glLightfv(GL_POSITION, pos) it is affected by the modelview matrix, so it does matter where you set the position and direction of the light.

I don´t get what you mean…

Rotate the light with the object??
Don´t think so…

my InitGL… :

// InitGL - initiate the ambient of the OpenGL Canvas
void C3DPaintCanvas::InitGL()
// set the lights
GLfloat lightPos[4]={ 0.0, 0.0, -100.0, 0.0 }; //{0.0f,350.0f,350.0f,0.0f};
GLfloat specref[4]={1.0f,1.0f,1.0f,1.0f};
GLfloat ambientLight[4]={0.4f,0.4f,0.4f,1.0f};
GLfloat diffuseLight[4]={0.8f,0.8f,0.8f,1.0f};
GLfloat specularLight[4]={0.1f,0.1f,0.1f,1.0f};

// set the projection matrix to unit matrix

// create the coordinate system

// reset modelview matrix stack

glEnable(GL_DEPTH_TEST);//Ordenamiento de pixeles de acuerdo a su distancia z
//glEnable(GL_CULL_FACE);//No muestra partes posteriores

glEnable(GL_LIGHTING);//Habilita luces
glEnable(GL_LIGHT0);//Habilita la luz 0
glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);//Asigna los valores de la luz 0

glEnable(GL_COLOR_MATERIAL);//Habilita el ajuste de color para manejar la transparencia en 3D
//y la asignación de color al objeto3D
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);//Permite utilizar transparencia

glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);//Ajuste las propiedades del material para seguir los valores glColor
//Todos los materiales a partir de ahora tendran reflección especular total con un alto brillo
glClearColor(0.0f,0.0f,0.0f,1.0);//Ajusta el color de blanqueo (fondo en negro)


Are you doing any “camera” transformations, such as using gluLookAt()? If you want the light to remain in position while the object rotates the order or operations would be something like this…

glLightfv(GL_LIGHT0, GL_POSITION, lightpos);

Also for your light position you are using (0.0, 0.0, -100.0, 0.0). You may already realize this, but this position is actually specifying a directional light, not a positional light. As a directional light, these values are a vector showing the direction of the light. I could be wrong, but I don’t think the magnitude of the vector is taken into consideration so the (0.0, 0.0, -1.0, 0.0) is an equivalent light direction. If you actually want a position, which I think is what you want, then you should make that fourth value a 1 like so (0.0, 0.0, -100.0, 1.0).