###########################
Rendering a Window Contents
###########################

.. code:: cpp

    // First, get our resource manager and access its interface.
    RED::Object* resmgr = RED::Factory::CreateInstance( CID_REDResourceManager );
    RED::IResourceManager* iresmgr = resmgr->As< RED::IResourceManager >();

    // Close our transaction first, otherwise our changes won't be commited!
    RC_TEST( iresmgr->EndState() );

    // Assuming that 'window' is our HOOPS Luminate window address:
    RED::IWindow* iwindow = window->As< RED::IWindow >();

    // Rendering method (GPU rendering):
    RC_TEST( iwindow->FrameDrawing() );

    // Rendering method (CPU rendering or hybrid CPU / GPU rendering):
    bool complete = false;
    while( complete == false )
    {
        RC_TEST( iwindow->FrameTracing( complete ) );
        // Refresh user interface, poll application events here.
    }

    // Rendering is over, start a new transaction to record changes:
    iresmgr->BeginState();

The first important point here is about closing the current transaction before calling one of the ``RED::IWindow`` rendering methods. If the current transaction is not closed before drawing, then all changes done recorded during that transaction will be ignored. See the :doc:`/book/subjects/bk_ba/bk_ba_transaction_management` chapter for details on how transaction work in HOOPS Luminate.

Then, draw. Depending on the cluster's rendering setup (:doc:`/book/subjects/bk_ba/bk_ba_software_startup`), one of the two methods indicated in the code above can be chosen. ``RED::IWindow::FrameDrawing`` is preferred for pure GPU accelerated rendering. ``RED::IWindow::FrameTracing`` is used for CPU side image processing using HOOPS Luminate's software ray-tracer, possibly mixed with hardware GPU rendering.

Then, once drawn, re-open a transaction. All changes in the engine will fail if a transaction is not open to record changes. 