I was only vaguely aware of the importance of re-positioning the light every time, but it appears that I’ve been doing it all the time by coincidence. It still won’t work, and the shapes are not deformed or anything. You can download a demonstration from:
http://www.netsonic.fi/~jade6/3Demo/LightDemo.exe
Here’s some example code; I’m using Delphi at the moment, although I’ll probably soon move to C++. I hope it doesn’t matter that much… using Delphi, I mean.
By the way, I would also greatly appreciate any help with exporting this stuff into web-deployed ActiveX; I managed to do it once, but usually OpenGL starts drawing before the IE Device Context becomes available, and I have no idea how to fix that.
procedure TForm1.FormPaint(Sender: TObject);
begin
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glPushMatrix;
glTranslatef(2.2, 1.8, 2.3);
GLLight1.Draw;
glPopMatrix;
//
// Various push-pops and geometry drawing
//
GLScreen1.Swap;
end;
…and the light-class draw method looks like this. Note that I’m using two-sided material colouring and lighting since many of the primitives are at least partially open.
procedure TGLLight.Draw;
begin
if FActive then begin
glEnable(FSource);
end else begin
glDisable(FSource);
exit;
end;
glLightfv(FSource, GL_POSITION, @FLocation);
glLightfv(FSource, GL_DIFFUSE, @FDiffuse);
glLightfv(FSource, GL_SPECULAR, @FSpecular);
if FSpotLight then begin
glLightfv(FSource, GL_SPOT_CUTOFF, @FCutOff);
glLightfv(FSource, GL_SPOT_DIRECTION, @FDirect);
end;
end;