implemented D3D access API + lost device handling + mode change
included the external changes with d3d detection