(SOLVED)Error during device creation (D3DERR_NOTAVAILABLE)

Started by
0 comments, last by vanattab 11 years, 7 months ago
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.

[source lang="vb"]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[/source]
Advertisement
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. Thanks.

This topic is closed to new replies.

Advertisement