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:
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);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glTranslatef(2.2, 1.8, 2.3);
// Various push-pops and geometry drawing
…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.
if FActive then begin
end else begin
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);