###################
Setup a Point Light
###################

A point light originates from a single position and spreads outward in all directions.

First you need to create 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 >();

Then you define the point light:

.. code:: cpp 
        
    // The point light parameters:
    RED::Vector3 position = RED::Vector3( 20.0, 20.0, 60.0 );
    RED::Color diffuse = RED::Color::WHITE;
    RED::Color specular = RED::Color::WHITE;
    float att_values[7] = { 1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f };

    // Define the light as point:
    RC_TEST( ilight->SetPointLight( RED::ATN_NONE, att_values, position, diffuse, specular, iresmgr->GetState() ) );

See the :doc:`/book/subjects/bk_sgo/bk_sgo_ls/bk_sg_decay_equations` chapter to learn about light attenuation modes and settings.

Finally you add the light to the camera:

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