Alexander Van Atta
Alexander Van Atta

Reputation: 890

Error during device creation (D3DERR_NOTAVAILABLE)

I am trying to convert the SlimDX device creation tutorial from DX11 to DX9. It is a very simple tutorial where you create a windows add a dx9 device and fill the screen with a solid color. However I am getting a D3DERR_NOTAVAILABLE error thrown when I try and create the device. All the code seems to make sense and it looks very similar to the C# code used in the samples. Any Ideas? NOTE: I create a instance of the BaseDisplayclass and call the InitSlimDX method in another class.

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

Upvotes: 0

Views: 1930

Answers (1)

Alexander Van Atta
Alexander Van Atta

Reputation: 890

I figured out what my problem was. Earlier I was messing with my DX9 settings in the DirectX control panel and for some reason I enabled the "Software Only" setting which disabled hardware acceleration. disabling this option fixed the issue.

Upvotes: 1

Related Questions