Simple ofLight question

Does the following call:

pointLight.setDiffuseColor(lightColor);

do anything on its own, or is this function only useful in conjunction with a subsequent call to ofSetColor like this one?:

ofSetColor(pointLight.getDiffuseColor());

Thanks!

Hi,

Yeah so once you have set the diffuse color you want to light to have later when you enable lighting this is what it will use.

ofSetColor will affect the color of the object that you draw, when lighting is enabled the color (or the material color if you have one bound) and the color of the light (plus all it’s other properties) will determine the final output color.

There’s an example called singleLightExample in the openFrameworks example folder which shows how it all works, I’ve got something here as well which is even shorter/simpler (if you ignore where it makes a terrain): https://github.com/andreasmuller/NoiseWorkshopScratchpad/blob/master/NoiseTerrain/src/ofApp.h#L83

1 Like

Thanks!