Creating a 2D image

RED::Object* image_2d;

// Create the image.
RC_TEST( iresmgr->CreateImage2D( image_2d, iresmgr->GetState() ) );

RED::IImage2D* i2d = image_2d->As< RED::IImage2D >();

// Let the engine to allocate the image 1024 x 1024 (POTD) pixels array for us.
RC_TEST( i2d->SetLocalPixels( NULL, RED::FMT_RGB, 1024, 1024 ) );

unsigned char* pixels = i2d->GetLocalPixels();
for( int y = 0; y < 1024; ++y )
  for( int x = 0; x < 1024; ++x )
    // Fill in the texture...

// Set the texture content to the renderer.
RC_TEST( i2d->SetPixels( RED::TGT_TEX_2D, iresmgr->GetState() ) );

This code sample creates a 2D image, uses REDsdk to allocate a local pixel array in the image and uploads the contents of this local pixel array in the engine (therefore on the GPU if REDsdk uses GPU rendering, and in CPU memory is REDsdk uses software rendering). The local pixel array remains. It can be deleted if not needed anymore using RED::IImage2D::ClearLocalPixels.