2016-11-01 43 views
0

整個代碼很長。 所以我只會在這裏添加相關的行。爲什麼我在Microsoft.DirectX.Direct3D.Device上出現錯誤?

在表單的頂部:

private Device D3Ddev = null; 

設備是Microsoft.DirectX.Direct3D.Device

然後:

private Boolean InitializeDirectX() 
     { 

       DispMode = Manager.Adapters[Manager.Adapters.Default.Adapter].CurrentDisplayMode; 
       D3Dpp = new PresentParameters(); 
       D3Dpp.BackBufferFormat = DispMode.Format; 
       D3Dpp.PresentFlag = PresentFlag.LockableBackBuffer; 

       D3Dpp.SwapEffect = SwapEffect.Discard; 
       D3Dpp.PresentationInterval = PresentInterval.One; //wait for vertical sync. Synchronizes the painting with 
       //monitor refresh rate for smoooth animation 
       D3Dpp.Windowed = true; //the application has borders 

      try 
      { 
       D3Ddev = new Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, pictureBox1.Handle, 
                      CreateFlags.SoftwareVertexProcessing, D3Dpp); 
       D3Ddev.VertexFormat = CustomVertex.PositionColored.Format; 
       D3Ddev.RenderState.Lighting = false; 
       D3Ddev.RenderState.CullMode = Cull.CounterClockwise; 

       backTexture = TextureLoader.FromStream(D3Ddev, mymem); 
       scannedCloudsTexture = new Texture(D3Ddev, 512, 512, 1, Usage.Dynamic, Format.A8R8G8B8, Pool.Default); 

       //sprite is used to draw the texture 
       D3Dsprite = new Sprite(D3Ddev); 

       return true; 
      } 
      catch 
      { 
       Logger.Write("error"); 
       return false; 
      } 
     } 

該錯誤是就行:

D3Ddev.VertexFormat = CustomVertex.PositionColored.Format; 

關於For墊。

嚴重級代碼說明項目文件行抑制狀態 錯誤CS0012類型'IsConstModifier'在未引用的程序集中定義。您必須添加對程序集「Microsoft.VisualC,Version = 7.0.5000.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a」的引用。 DopplerEffect.cs 467 Active

+0

的託管DirectX庫是非常,非常古老,已經廢止之前.NET 2.0運。微軟不再想支持它,那不是因爲它是一個很棒的圖書館。您錯過了依賴關係,回到Visual Studio 2002.繼續使用這個庫的開源替代品,比如SharpDX和SlimDX。 –

回答

0

由於它聲明您需要添加對程序集「Microsoft.VisualC」的引用。

搜索在某處 「C:\ WINDOWS \ Microsoft.NET \框架\ V2.0.50727 \ Microsoft.VisualC.dll」

相關問題