I am creating my first real game demo and am spending FAR too jmuch time on the lighting. The way it works is that when you fire in the game, one of the bullets in the array is activated and then every bullet in the array is moved forward and rendered at update.
The thing is I have mada a simple light model (ambient with a bit of specular) but when I press fire (and GlutSolidSphere is called) it turns off the lights. I have removed this line and it is fine, is this a known problem and is there a way around it?
static void
initQuadObj(void)
{
quadObj = gluNewQuadric();
if (!quadObj)
__glutFatalError(“out of memory.”);
}
void APIENTRY
glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we’d need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}
So it must be your code. Perhaps you want to show some of it?
otherwise you are still doing everything in the projection matrix mode, which wont work (the projection matrix mode only has a depth of two stack entries).
I remember something similiar to this hapenning to me… I recall it having to do something with GL_COLOR_MATERIAL but I don’t exactly know… Try taking those glEnable and glDisable lines out and just draw the sphere and see what it does…
Tried both the above and no joy Thanks for your help though guys, guess I will just have to pull my code to bits and see if i can get to the bottom of it that way.
The enable color material call will set the materials to the current color. The default is front_and_back, ambient_and_diffuse. The glutSolidSphere has no colors. If your color was black before, you’re screwed.
It’s one of OpenGL pitfalls described in the so-named doc on the main page: http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/ see #14.
This is one of the reasons why it’s clever to set parameters first and call enable as last.
I think if you do a glPushAttrib(GL_ALL_ATTRIB_BITS), draw your glut sphere, and then pop them off again it might work… I had a similar problem before.