I’ve got a problem with OpenGL lighting.
My problem is that all the lights switch off when my objects are in a given position.
When I start my app, everything is Ok I got a model (MD2) drawn in front of me and I can rotate it along Y axis (vertical). So at about 60° the lights are sitched off (I can just see the shape of model) everything is black.
When I resume the rotate and it comes back to the begnning the light is switched on.
I look at the light status and I told me that it’s ON.
But I must have a problem with glLookAt()…and the rotating translating methods.
But I’ve followed somes exemples and my code is the same…
I must be something so easy that I can see it in my jungle Code
So if someone had ever seen that…help me
Thanks for all and sorry for my poor english.
I’ve got a problem with OpenGL lighting.
you might want to check you light’s position.
… esp. when you set it!
If you set the light’s position AFTER you have specified the modelview matrix for your object, the light’s position or direction vector will be transformed by that matrix.
To get a light in a fixed position or direction specify it while your modelview matrix is identity, that is, outside your object’s transform operations.
I don’t know what it’s wrong in my code.
Let’s see my render function (it’s only in this function that I would like to implement light):
glDrawElements(seg->RDS.faceType,seg->RDS.num_vertices * seg->num_faces,GL_UNSIGNED_INT,seg->faceindex_list);
glEnd();// Done The Faces
I would like to have a light that shine my model and that d’ont move when my “camera” and my object move.
If my object rotates the light is fixed to the world and it shines the model only on faces that are exposed to the light (want a fixed light at a position that shine my world)
Please let me see where you put the ligth code and how it works …
Because I put my light code everywhere I can and I never had what I want.
I’ve found the problem listed A the top concerning Light Switching (it was due to 2 mistake glEnbale(GL_NORMALIZE) that I was thinking Enabled by default and by the fourth parameter of my position light(forgotten).
But my light still moves with my point of vue.
How to correct that??
EveryWhere I place the light, it’s not what I want.
Please Help a poor mouse
Have you tried positioning the light just after the “camera” transformations, or with an identity matrix? When you call glLightfv to set the position, that position will be affected by the current modelview matrix.
Yes I’ve already done this:
Then it ligth correclty my object the camera doesn’t affect my light: BUT when I rotate my object just after, it’s all the time the same faces that are lighted.
if I put this line after objectif translation and rotation it’s the same.
I don’t know why but Rotating my light position=(x=0,y=0,z=15) with GlRotate just before the line has no effect on the lighting.
I Don’t know how to get object moving indépendant of light.
It seems that glRotate doesn’t affect GL_POSITION of light parameter!!!
Is that true?
is with no effect on light position??
If it’s true tell me.
If it’s that my problem is basic
Please can anyone answer that?
It should have an effect depending on where you placed your light. A 3 degree rotation isn’t a lot, so depending on where you set the light it might not be very apparent. And if you’re light is at 0,0,0 you won’t notice any change at all.
For your problem, have you also tried putting the light positioning BEFORE gluLookAt? gluLookAt will also affect your current matrix.
Yes I’ve already think about that (a little translation form 0,0,0 isn’t quite enough to be seen)
Thanks for all, I’ve found my problem
It was a mistake in my pointer normal area.
The pointer as been confused with color area.
So by chance (or evil lol) when the object was moving , the normals affect the lightning as if the light was moving.
Stupid mistake of mine, that kept me out.
I was nearly thinking that I had understood no more thant a bit in OpenGL
Thanks for all 'cause you drive me to found my mistake with your checking list.