void CDlgCreateSpecularTexture::DrawPreview( CDrawPort *pdp, FLOAT fExp)
{
  BOOL bErrorOcured = FALSE;
  
  if( (m_moModel.GetData() == NULL) || (m_moModel.mo_toTexture.GetData() == NULL) ||
      (m_moModel.mo_toSpecular.GetData() == NULL) )
  // obtain components for rendering
  try
  {
    DECLARE_CTFILENAME( fnBCGTexture, "Models\\Editor\\SpecularPreviewBCG.tex");
    m_toBackground.SetData_t( fnBCGTexture);

    DECLARE_CTFILENAME( fnTeapotModel, "Models\\Editor\\Teapot.mdl");
    DECLARE_CTFILENAME( fnTeapotTexture, "Models\\Editor\\Teapot.tex");
    m_moModel.SetData_t( fnTeapotModel);
    m_moModel.mo_toTexture.SetData_t( fnTeapotTexture);
    m_moModel.mo_toSpecular.SetData_t( CTString("temp\\SpecularTemp.tex"));
  }
  catch( char *strError)
  {
    (void) strError;
    bErrorOcured = TRUE;
  }

  if( !bErrorOcured)
  {

    ((CModelData*)m_moModel.GetData())->md_colSpecular = m_colorSpecular.GetColor();
    PIXaabbox2D screenBox = PIXaabbox2D( PIX2D(0,0), PIX2D(pdp->GetWidth(), pdp->GetHeight()) );
    //pdp->PutTexture( &m_moModel.mo_toSpecular, screenBox);
    //return;
    pdp->PutTexture( &m_toBackground, screenBox);
    pdp->FillZBuffer( ZBUF_BACK);

    CRenderModel rmRenderModel;
    CPerspectiveProjection3D prPerspectiveProjection;

    a3dObjectAngles += a3dObjectRotation;
    a3dLightAngles += a3dLightRotation;

    m_plPlacement.pl_OrientationAngle = a3dObjectAngles;
    AnglesToDirectionVector( a3dLightAngles, rmRenderModel.rm_vLightDirection);

    prPerspectiveProjection.FOVL() = AngleDeg(50.0f);
    prPerspectiveProjection.ScreenBBoxL() = FLOATaabbox2D( 
      FLOAT2D(0.0f,0.0f),FLOAT2D((float)pdp->GetWidth(), (float)pdp->GetHeight()));
    prPerspectiveProjection.AspectRatioL() = 1.0f;
    prPerspectiveProjection.FrontClipDistanceL() = 0.05f;

    prPerspectiveProjection.ViewerPlacementL().pl_PositionVector = FLOAT3D(0.0f,0.0f,0.0f);
    prPerspectiveProjection.ViewerPlacementL().pl_OrientationAngle = ANGLE3D( 0, -20, 0);
    prPerspectiveProjection.Prepare();
    CAnyProjection3D apr;
    apr = prPerspectiveProjection;
    BeginModelRenderingView(apr, pdp);

    _mrpModelRenderPrefs.SetRenderType( RT_TEXTURE|RT_SHADING_PHONG);
    m_plPlacement.pl_PositionVector = FLOAT3D( 0.0f, -0.19f, -0.35f);
    rmRenderModel.SetObjectPlacement(m_plPlacement);
    rmRenderModel.rm_colLight = m_colorLight.GetColor();
    rmRenderModel.rm_colAmbient = m_colorAmbient.GetColor();
    m_moModel.SetupModelRendering(rmRenderModel);
    m_moModel.RenderModel(rmRenderModel);
    EndModelRenderingView();
  }


  /*
  pdp->Fill(C_GREEN|CT_OPAQUE);
  PIX pixSizeI = pdp->GetWidth();
  PIX pixSizeJ = pdp->GetHeight();
  for (PIX pixI=0; pixI<pixSizeI; pixI++) {
    for (PIX pixJ=0; pixJ<pixSizeJ; pixJ++) {
      FLOAT fX = pixI*2.0f/pixSizeI-1;
      FLOAT fY = pixJ*2.0f/pixSizeJ-1;
      FLOAT fZ;
      FLOAT fZ2 = 1-fX*fX-fY*fY;
      if (fZ2<0) {
        fZ = 0;
      } else {
        fZ = Sqrt(fZ2);
      }
      FLOAT fZN = FLOAT(pow(fZ, fExp));
      ASSERT(fZN>=0 && fZN<=1);
      UBYTE ub = UBYTE(fZN*255);
      pdp->Fill(pixI, pixJ, 1,1, RGBToColor(ub,ub,ub)|CT_OPAQUE);
    }
  }
  */
}