PDA

View Full Version : glColour3f doesn't work on my gluSphere



gimp
02-12-2001, 09:34 PM
Here is some code:

/*-----------------------------------------------------------------------------
Slow and nasty wireframe sphere drawing. Upside is it requires no storage.
-----------------------------------------------------------------------------*/
void CSphere: :Draw(void) const
{
glPushAttrib(GL_LIGHTING_BIT | GL_CURRENT_BIT);
glDisable(GL_LIGHTING);
glPushMatrix();

glTranslatef(m_Centre.x, m_Centre.y, m_Centre.z);
glColor3f(1.0f,1.0f,1.0f);

GLUquadricObj *SphereObj = gluNewQuadric();
gluQuadricDrawStyle(SphereObj, GLU_LINE);
gluSphere(SphereObj, m_Radius, 15, 10);
gluDeleteQuadric(SphereObj);

glPopMatrix();
glPopAttrib();
}

As you can see I've tried to insulate the function from my main codebase, though for some reason the wireframe still remains black...

Note : This functions is a simple way for me to see a sphere primitive in game, hence I don't use any local storage. This is used to see bounding spheres during collision test debugging.

Many thanks

Chris

[This message has been edited by gimp (edited 02-12-2001).]

Pete Bassett
02-13-2001, 04:42 AM
When using GL lighting you need to specify materials for objects you draw.

Although I always thought the default material was solid white, not black.

Pete

Bob
02-13-2001, 05:07 AM
Try use glutWireSphere instead, just to see that nothing is wrong with the way you draw your sphere.

gimp
02-13-2001, 02:08 PM
glutWireSphere(m_Radius,15,10);

Probably should have used that from the beginning. The problem however isn't fixed..

As a matter of interest, I placed a light next to the object within the sphere and it gets lit while the sphere does not.

Then I commented out the disabling of lighting in the above function. The sphere is not affected by lighting.

This is quite odd...

thasmin
02-13-2001, 05:06 PM
Try looking at gluQuadricNormals.

gimp
02-13-2001, 08:09 PM
I have lighting turned off, what would normals have anything to do with it? Besides I'm now using glutWireSphere.

Any other takers?

gimp
02-14-2001, 09:50 PM
Got it!

I was screwing with the texture loader when it broke. All the spheres turned white.


!!!

The Sphere was attempting to use the currently bound texture.

That means I have a few things to fix...