Matt Nash
05-03-2001, 03:40 AM
I got this stuff from a tutorial on Dirextx 8, but I can't get it to work. I keep getting an automation error when creating the device.
Someone please help
Thanks, Matt
<font color=blue>Dim Dx As DirectX8
Dim D3D As Direct3D8
Dim D3DDevice As Direct3DDevice8
Dim bRunning As Boolean
Private Sub Form_Load()
Me.Show
bRunning = Initialise
Do While bRunning
Render
DoEvents
Loop
Set D3DDevice = Nothing
Set D3D = Nothing
Set Dx = Nothing
Unload Me
End
End Sub
Public Function Initialise() As Boolean
Dim Dispmode As D3DDISPLAYMODE
Dim D3DWindow As D3DPRESENT_PARAMETERS
'On Error GoTo ErrHandler
Set Dx = New DirectX8
Set D3D = Dx.Direct3DCreate
D3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, Dispmode
D3DWindow.Windowed = 1
D3DWindow.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
D3DWindow.BackBufferFormat = Dispmode.Format
Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmMain.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)
Initialise = True
Exit Function
'ErrHandler:
'Initialise = False
End Function
Public Sub Render()
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &HCCCCFF, 1#, 0
D3DDevice.BeginScene
'Render stuff here
D3DDevice.EndScene
D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
End Sub
</font color=blue>
Someone please help
Thanks, Matt
<font color=blue>Dim Dx As DirectX8
Dim D3D As Direct3D8
Dim D3DDevice As Direct3DDevice8
Dim bRunning As Boolean
Private Sub Form_Load()
Me.Show
bRunning = Initialise
Do While bRunning
Render
DoEvents
Loop
Set D3DDevice = Nothing
Set D3D = Nothing
Set Dx = Nothing
Unload Me
End
End Sub
Public Function Initialise() As Boolean
Dim Dispmode As D3DDISPLAYMODE
Dim D3DWindow As D3DPRESENT_PARAMETERS
'On Error GoTo ErrHandler
Set Dx = New DirectX8
Set D3D = Dx.Direct3DCreate
D3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, Dispmode
D3DWindow.Windowed = 1
D3DWindow.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
D3DWindow.BackBufferFormat = Dispmode.Format
Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmMain.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)
Initialise = True
Exit Function
'ErrHandler:
'Initialise = False
End Function
Public Sub Render()
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &HCCCCFF, 1#, 0
D3DDevice.BeginScene
'Render stuff here
D3DDevice.EndScene
D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
End Sub
</font color=blue>