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.WindowsImports SlimDX.Direct3D9Imports SlimDXImports Device = SlimDX.Direct3D9.DeviceImports Resource = SlimDX.Direct3D9.ResourceImports System.Windows.Forms.ThreadExceptionDialogImports System.IOPublic Class BaseDisplay Inherits RenderForm'SlimDX Class VarsProtected device As Device = NothingProtected backBuffer As SurfaceProtected presentParams As PresentParametersPublic Sub New() Show()End SubPublic 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 SubPublic Overloads Sub Dispose() device.Dispose() MyBase.Dispose()End SubEnd Class[/source]
1 reply to this topic
Members - Reputation: 188
Posted 24 September 2012 - 07:58 AM
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.