Setting up a Device.

Miura

Freshman
Joined
Mar 13, 2003
Messages
27
Hi,

I'm almost lost in this. I started with GDI+ but it is very slow on the alpha effects. So I just started with DirectX9 for Visual Basic .Net. So I tried to setting up a Device with DirectX3D, but I get a error.

Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D

Public Class Form1
Inherits System.Windows.Forms.Form

Dim createdevice As Device
Dim presentpara As New PresentParameters()

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.FormBorderStyle = FormBorderStyle.None
Me.Text = ""
Me.WindowState = FormWindowState.Maximized
System.Windows.Forms.Cursor.Hide()
presentpara.Windowed = True
createdevice = New Device(0, DeviceType.Software, Me, CreateFlags.SoftwareVertexProcessing, presentpara)

End Sub
End Class

I get a error in the last Cretedevice line, can someone tell me why ?

Thanks,
Miura
 
First, Read the tutorial on Direct3D9 at www.directx4vb.com
Secondly, those display parameters are incorrect:
Visual Basic:
'Windowed Mode Display parameters
With displaypara
       .Windowed = True 'Windowed Mode
       .SwapEffect = SwapEffect.Discard
       .BackBufferCount = 1 '1 Back Buffer
       .BackBufferFormat = D3DManagerObj.Adapters(0).CurrentDisplayMode.Format 'Use current Depth
       .BackBufferWidth = Me.ClientSize.Width() 'Set render area to
       .BackBufferHeight = Me.ClientSize.Height() 'form width/height
End With
'Now create Device
 
Thanks,

How do you know that these lines are incorrect or missing. I just
got an error how tells that someting it incorret or missing in line

createdevice = New Device(0, DeviceType.Software, Me, CreateFlags.SoftwareVertexProcessing, presentpara)

Where can I see what there is missing and incorrect ?

Regards,
Miura
 
You MUST specify the current screen color depth(if not in fullscreen) along with the the BackBuffer Sizes and count

There doesn't seem to be anything wrong with that line but it is telling you that some of the information IN the line is incorrect and the presentation parameters are the only things that seem incorrect
 
To see more detailed error messages, including parameters that are missing or invalid, use the dbmon tool.

1. Run DBMon (found in C:\DXSDK\Bin\DXUtils\dbmon.exe)
2. Run your application in VS.NET
3. When your program halts with an exception, look at the command window opened by dbmon - you should see a good description of what went wrong.

You can also have error information spewed out to your VS.NET Output window though you'll get a LOT more than just DirectX information. To turn it on, goto you project properties and select the "Configuration Properties" folder, then the "Debugging" subitem. Change "Enable Unmanaged Debugging" to True. Now in your Output window you'll see something like (I cut out 50 lines of "loading DLL..." information):
Code:
<snip>
D3DX: (INFO) Using SSE2 Instructions
Miss rate before optimization: 1.000000
Miss rate after optimization: 1.000000
Miss rate before optimization: 2.571141
Miss rate after optimization: 1.214765
D3DX: (INFO) Using SSE2 Instructions
The thread '.NET SystemEvents' (0x33c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x33c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x2f0) has exited with code 0 (0x0).
The program '[3972] Billboard.exe' has exited with code 0 (0x0).
The program '[3972] Billboard.exe: Native' has exited with code 0 (0x0).

-Nerseus
 
Back
Top