By default OpenGL doesn't like negative scaled objects for lighting purposes. Whilst you would think a negative scale would just flip the normals - and causing shading to invert - actually the lighting itself gets inverted too, exchanging what's considered 'back' and 'front' face.
This first picture illustrates this, with the bottom two spheres being normal scaled, and the upper two negative scaled. By both having normals flipped and having back/front exchanged, the result of a flipped Object still looks "OK".
This is the situation when double sided lighting is used in OpenGL. Because of the back/front switch the sphere renders black entirely.
Disabling "Double Sided" in Blender therefore was the usual bypass advised when you use negative scaled Objects.
Solution therefore is calculating whether an Object has a 'flipped' matrix. Luckily there's a simple and reliable method for it:
(From blenkernel/intern/object.c, in where_is_object() )
<ccode>
/* set negative scale flag in object */
Crossf(vec, ob->obmat[0], ob->obmat[1]);
if( Inpf(vec, ob->obmat[2]) < 0.0 ) ob->transflag |= OB_NEG_SCALE;
else ob->transflag &= ~OB_NEG_SCALE;
</ccode>
Just take a cross product for the 2 first rows of the transformation matrix, and compare that (dot product) with the third row.
While drawing the front/back definition gets corrected:
<ccode>
if(ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
else glFrontFace(GL_CCW);
</ccode>
Third picture shows correct double-sided lighting in all 4 situations.
Finally, after so many years... :)