glutSolidSphere stops the light???

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?

Cheers for any help,

BennUK

Thats unlikley, since all glutSolidSphere() does is this:

static GLUquadricObj *quadObj;
#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); }

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?

With these parts commented out, it’s fine, as soon as I put the glutSolidSphere back, it dies. Hmmmn.

void CworldModel::renderBullets(void)
{
for(int i = 0; i < BULLET_AMOUNT; i ++)
{
if (player.getBulletState(i))
{
//glLoadIdentity();
glPushMatrix();
glTranslatef(player.getBulletPosition(i, 0) + 0.5, 45, player.getBulletPosition(i, 2));
glEnable(GL_COLOR_MATERIAL);
//glutSolidSphere(0.1, 16, 16);
glDisable(GL_COLOR_MATERIAL);
glPopMatrix();

	}
}

}

Thanks

BennUK

Have you changed your matrixmode to

glMatrixMode(GL_MODELVIEW);

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…

Hope it works, I don’t exactly remember

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.

BennUK

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.