From the picture back to the source

OpenGL code mirror

Every control on this page corresponds to exactly one line of fixed-function OpenGL. Change a control and its line lights up on the right; click a line and its control pulses. This is the direction you usually need — you know the look you want, and the question is what to type.

Result GL_FRONT_AND_BACK
Drag to move the light

The sphere is shaded with the exact equation the code on the right sets up, including attenuation and the emission term.

Your setup function click a line
Light type
Shininess
Normal length
GL_NORMALIZE
Light
GL_AMBIENT
GL_DIFFUSE
GL_SPECULAR
GL_POSITION
2.0
3.0
4.0
Material
GL_AMBIENT
GL_DIFFUSE
GL_SPECULAR
GL_EMISSION
32
Geometry & normals
1.00

Scaling the model scales its normals too. A normal of length other than one breaks the N·L term, so the object goes too dark or blows out. GL_NORMALIZE tells OpenGL to rescale every normal to unit length before lighting it.

Attenuation
0.00
0.000
Reading the code back
Notice what is not in this listing: nothing computes a colour. You hand OpenGL a light, a material and a normal per vertex, and the fixed-function pipeline evaluates the lighting equation itself, at the vertices, and interpolates between them. That division of labour is precisely what the programmable pipeline hands back to you — a fragment shader replaces this whole listing with arithmetic you write, which is why effects like cel shading become possible.