######################
Setup an Ambient Light
######################

The ambient light defines the base lighting of a scene. It represents a fixed-intensity and color light source affecting all objects equally. Consequently, it as no position, direction or decay and does not cast shadows. Its only paramter is its color.

First step: creating the light using the factory:

.. code:: cpp 
        
    // Create the light shape:
    RED::Object* light = RED::Factory::CreateInstance( CID_REDLightShape );
    if( light == NULL )
        RC_TEST( RED_ALLOC_FAILURE );

    RED::ILightShape* ilight = light->As< RED::ILightShape >();

Second step: setting the light as ambient:

.. code:: cpp 
        
    // Define the light as ambient:
    RC_TEST( ilight->SetAmbientLight( RED::Color::WHITE, iresmgr->GetState() ) );

Third step: adding the light to the camera scene graph:

.. code:: cpp 
        
    // Add the scene data to the viewpoint:
    RC_TEST( icamera->AddShape( light, iresmgr->GetState() ) ); 