SlimDX游戏WindowFullmode投掷错误

时间:2015-12-23 04:33:50

标签: c# slimdx

DxScreenCapture.cs

 public class DxScreenCapture
    {
        Device d;

        public DxScreenCapture()
        {
            PresentParameters present_params = new PresentParameters();
            present_params.Windowed = true;
            present_params.SwapEffect = SwapEffect.Discard;
            d = new Device(new Direct3D(), 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, present_params);
        }

        public Surface CaptureScreen()
        {
            Surface s = Surface.CreateOffscreenPlain(d, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, Format.A8R8G8B8, Pool.Scratch);
            d.GetFrontBufferData(0, s);
            return s;
        }
    }

捕获图像并序列化为发送服务器

 using (Surface s = cap.CaptureScreen())
            {

                BinaryFormatter bf = new BinaryFormatter();
               Bitmap bitmap = new Bitmap(SlimDX.Direct3D9.Surface.ToStream(s, SlimDX.Direct3D9.ImageFileFormat.Bmp));

                ns = client.GetStream();
                bf.Serialize(ns, bitmap); // ns = NetworkStream
            }

当游戏未运行状态良好时。 但游戏在全窗口模式下运行 引发豁免

SlimDX.Direct3D9.Direct3D9Exception

这是内部异常:

D3DERR_INVALIDCALL: Invalid call (-2005530516)

Excpetion Details

1 个答案:

答案 0 :(得分:0)

也许this answer也适合您的问题

  

我的猜测是你的显卡可能不支持1x1   后备缓冲

     

查看调试运行时的输出。每当你得到一个   InvalidCall很有可能存在某种诊断   那里的信息表明你做错了什么。