   renderToSurface problem,BeginScene returning invalid call
  code: if(FAILED( D3DXCreateTexture(lpD,widthNum*earchWidth,heightNum*earchHeight,1, D3DUSAGE_RENDERTARGET,D3DFMT_A8B8G8R8,  D3DPOOL_DEFAULT,&backTexture))) {   return FALSE; }if(FAILED( backTexture->GetSurfaceLevel(0,&backSurface)))  return FALSE; D3DSURFACE_DESC dec;backSurface->GetDesc(&dec;  if(FAILED(D3DXCreateRenderToSurface(lpD,dec.Width,dec.Height,  dec.Format,FALSE,D3DFMT_UNKNOWN,&lp_renderSurface))) return FALSE;  lpD->SetTexture(0,backTexture);    if (SUCCEEDED(lp_renderSurface->BeginScene(backSurface,NULL)))    {// render to surface but failed  }   
  Have a look to debug output information. Do you use debug runtime? If not see here how to do it..   ;  Is the D3DVIEWPORT9 parameter in BeginScene optional? Have you tried providing a value just to check?   ;  Random guess: The second parameter to ID3DXRenderToSurface::BeginScene cannot be null.EDIT: ninja'd   