Hi all,
I have a ATI All-In_Wonder 128 pro card with 4.13.7129 drivers (the latest ones) on Win98. I have a program that uses the stencil buffer to mirror a torus through a plane. (finally figured out the affine transformation for it too, yes!!) The stencil works fine. The problem is that I want to transform the light so the lighting looks correct on the mirrored object. I use a spotlight with a position and direction. So my code for drawing the mirrored object looks like this:
// Render the mirrored object
glPushMatrix();
{
// This does the affine transform for // mirroring everything
mirrorPlane(plane);
// reposition the light
// since the shading has to look like it’s
// correct glPushAttrib(GL_LIGHTING_BIT);
{
// Position the light glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
#if SPOTLIGHT MATHLIB::V3 lightDir(lightPos);
lightDir *= -1.0f;
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, lightDir.xyz);
#endif
glRotatef(rotateCube, 0.0f, 1.0f, 0.0f);
glRotatef(30.0f, 0.0f, 1.0f, 0.0f); glutSolidTorus(0.275f, 0.725f, 16, 16);
} glPopAttrib();
}
glPopMatrix();
Then I render the real torus:
// Render the cube
glColor4f(cColor[0], cColor[1], cColor[2], 1.0f);
glPushMatrix();
{
glPushAttrib(GL_LIGHTING_BIT);
{
// Position the light // glLightfv(GL_LIGHT0, GL_POSITION, // lightPos);
#if SPOTLIGHT
// This is a problem, double check!
// Doesn’t seem to set the light direction correctly.
// NOTE: Send this to opengl forum and
// ask people what they think
MATHLIB::V3 lightDir(lightPos);
lightDir *= -1.0f;
// glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, lightDir.xyz);
glGetLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, tempDir);
printf("After real change: Light Direction = (%0.3f, %0.3f, %0.3f)
", tempDir[0], tempDir[1], tempDir[2]);
#endif
glRotatef(rotateCube, 0.0f, 1.0f, 0.0f);
glRotatef(30.0f, 0.0f, 1.0f, 0.0f);
glutSolidTorus(0.275f, 0.725f, 16, 16);
} glPopAttrib();
}
glPopMatrix();
I have to manually set the direction of the light before rendering the real torus, otherwise it isn’t lit correctly.
Checking using glGetLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, …) says that the direction is correct but it doesn’t render correctly.
Has anyone else incountered this problem on the ATI drivers? SHould I email ATI about this?
THanks!!
Ben Schleimer