Materials and Textures

Thanks in advance for any help

When using materials, specular highlighting shows up fine. If I add texture mapping it seems the lighting isn’t there - the texture fully replaces the specular highlights.

Can you use materials/lighting and textures at the same time or are they mutually exclusive?

Thanks again for any help

Quick answer:
If your texture environment is set to modulate, then the final colour value (after lighting calculations, therefore with the specular highlight added to the diffuse/ambient/emissive) is MODULATED with the texture (therefore if the texel is dark red, then the maximum final fragment you could possibly get would be dark red - 1,1,1 (final colour value) * 0.25,0,0 (texel colour value) = 0.25,0,0).

This is the default way OpenGL works.
But another ‘mode’ was added in version 1.2 of OpenGL - the mode is called ‘separate specular’ mode. Basically, it does the diffuse/ambient/emissive lighting calculation first, then modulates (or whatever) with all the texture units, and then finally adds the specular lighting result onto this colour value. This has the effect of giving you nice clear specular highlights.

Below is a rough and ready way to enable it using standard 1.1 OpenGL (which is the one MS Windows uses by default), you should really check for the existance of the extension first, but it is pretty much supported by most cards on the market:-

#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8
#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA

glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT);

Thanks Knackered - That was exactly what I was looking for…