0

我正在尝试将 SlimDX 设备创建教程从 DX11 转换为 DX9。这是一个非常简单的教程,您可以在其中创建一个窗口,添加一个 dx9 设备并用纯色填充屏幕。但是,D3DERR_NOTAVAILABLE当我尝试创建设备时出现错误。所有代码似乎都有意义,并且看起来与示例中使用的 C# 代码非常相似。有任何想法吗?注意:我创建了一个类的实例并在另一个类中BaseDisplay调用该方法。InitSlimDX

Imports SlimDX.Windows
Imports SlimDX.Direct3D9
Imports SlimDX
Imports Device = SlimDX.Direct3D9.Device
Imports Resource = SlimDX.Direct3D9.Resource
Imports System.Windows.Forms.ThreadExceptionDialog
Imports System.IO

Public Class BaseDisplay
    Inherits RenderForm

'SlimDX Class Vars
Protected device As Device = Nothing
Protected backBuffer As Surface
Protected presentParams As PresentParameters

Public Sub New()
    Show()
End Sub

Public Sub InitSlimDX()
    Dim d3d As Direct3D = New Direct3D()
    Dim primaryAdaptor As AdapterInformation = d3d.Adapters().First()

    presentParams = New PresentParameters()
    With presentParams
        .BackBufferWidth = Me.ClientSize.Width
        .BackBufferHeight = Me.ClientSize.Height
    End With

    Me.device = New Device(d3d, primaryAdaptor.Adapter, DeviceType.Hardware, Me.Handle, CreateFlags.HardwareVertexProcessing, presentParams)
    Me.device.BeginScene()
    backBuffer = device.GetBackBuffer(0, 0)
    Me.device.ColorFill(backBuffer, New Color4(Color.CornflowerBlue))
    Me.device.EndScene()
    Me.device.Present()
End Sub

Public Overloads Sub Dispose()
    device.Dispose()
    MyBase.Dispose()
End Sub
End Class
4

1 回答 1

1

我弄清楚我的问题是什么。早些时候,我在 DirectX 控制面板中弄乱了我的 DX9 设置,出于某种原因,我启用了禁用硬件加速的“仅软件”设置。禁用此选项可解决此问题。

于 2012-09-25T18:32:26.860 回答