#####################
Creating a Text Shape
#####################

The creation of a text shape is similar to the creation of all other HOOPS Luminate shapes, except that it uses the ``CID_REDTextShape`` value as parameter of the ``RED::Factory::CreateInstance`` call:

.. code:: cpp

    // Create the text shape:
    RED::Object* text = RED::Factory::CreateInstance( CID_REDTextShape );
    if( text == NULL )
    RC_TEST( RED_ALLOC_FAILURE );

    // Access its RED::ITextShape interface and assign a font to it:
    RED::ITextShape* itext = text->As< RED::ITextShape >();
    RC_TEST( itext->SetFont( font, iresmgr->GetState() ) );

The text shape will show something only if:

    1. It has a font assigned to it.
    2. It has a string to display!
    3. It's part of the scene graph being drawn.

Strings can be easily added to text shapes:

.. code:: cpp

    // Adding a string to display:
    RC_TEST( itext->AddString( "MyFirstString!", RED::Vector3( 10.0, 50.0, 100.0 ), RED::TAP_CENTER, iresmgr->GetState() ) );

Then, the text string should appear centered in 3D at the position specified by ``RED::Vector3`` ( 10.0, 50.0, 100.0 ). 
