Hi all.
I am trying to work with DirectX8,but with no luck.
I downloaded this source (from a toturial) and I can't get it to work.
it keeps on failing in the marked line.
the value I get for this variable = Nothing .
any Ideas ???
'The parent DirectX object
Dim objDX As DirectX8
'an instance of Direct3D (which I like to Call DirectGraphics,
'which is what it's called in the SDK)
Dim objDG As Direct3D8
'The device which will be rendering the graphic
Dim devDG As Direct3DDevice8
'A boolean to store whether or not DG was actually initialised
Dim DGInited As Boolean
'a boolean to help check if we can end the program safely
Dim ProgramExiting As Boolean
'---
'Form_Load:
'Loads when the program starts, the purpose of this subroutine
'is to call the initialisation commands and control the rendering
'loop.
'---
Private Sub Form_Load()
'Shows the Form
Me.Show
'lets the user know that D3D is initialising
Me.Caption = "Create Device: Initialising"
'Create a new, seperate existance of DirectX8
Set objDX = New DirectX8
'Call the DG init function and store it's success in a boolean
DGInited = D3DInit()
'If the initialisation failed, then end the program with an
'error message
If DGInited = False Then
MsgBox ("Critical Failure"
End
End If
'Initialisation finished, so update the title
Me.Caption = "Create Device"
'loop until the program wants to close
Do
'Clear the view port with a nice lovely blue
Call devDG.Clear(0, ByVal 0, D3DCLEAR_TARGET, &HFF0080FF, 1#, 0)
'All rendering commands must be issued within the
'.Beginscene and .EndScene commands, but rendering will be
'covered later.
devDG.BeginScene
devDG.EndScene
'The present command actually displays the backbuffer to
'the user, Note: by using a backbuffer, it stops flicker.
Call devDG.Present(ByVal 0, ByVal 0, 0, ByVal 0)
'Let the user click on the close button
DoEvents
Loop Until ProgramExiting = True
'Durh...
End
End Sub
'---
'D3DInit:
'Initialises DirectGraphics
'---
Function D3DInit() As Boolean
'Stores the current display mode (We'll use this to get the
'current pixel format for the backbuffer)
Dim udtCurrentMode As D3DDISPLAYMODE
'stores information reguarding how the image is presented to
'the user
Dim udtPParam As D3DPRESENT_PARAMETERS
'If an error occurs, go to the ErrorCheck and report an Init
'failure
On Error GoTo ErrorCheck
'Create an instance of DirectGraphics
Set objDG = objDX.Direct3DCreate
'Get the information relating to the current adaptor's mode
Call objDG.GetAdapterDisplayMode(D3DADAPTER_DEFAULT, udtCurrentMode)
With udtPParam
'The progarm will be in a window (1 = true)
.Windowed = 1
'The program will use a copy, not a flip to display
.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
'The backbuffer's pixel format will be the same as that of
'the current screen mode
.BackBufferFormat = udtCurrentMode.Format
End With
'create the device using Hardware if available, use the primary
'monitor with software vertex processing (I'll post another
'tutorial about that later...
Set devDG = objDG.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, udtPParam)
'If something went wrong out, spit out a Macintosh error and
'quit
If devDG Is Nothing Then GoTo ErrorCheck
'It was obviously successful, quit the function
D3DInit = True
Exit Function
ErrorCheck:
D3DInit = False
End Function
'---
'Form_Unload:
'Destroys objects to avoid memory leaks
'---
Private Sub Form_Unload(Cancel As Integer)
'Destroy the DirectGraphics Device
Set devDG = Nothing
'Destroy the DirectGraphics object
Set objDG = Nothing
'The program will not continue processing
ProgramExiting = True
End Sub
Sub dxf(SourceRect As Long, DestRect As Long, DestWindowOverride As Long, DirtyRegion As Long)
End Sub
I am trying to work with DirectX8,but with no luck.
I downloaded this source (from a toturial) and I can't get it to work.
it keeps on failing in the marked line.
the value I get for this variable = Nothing .
any Ideas ???
'The parent DirectX object
Dim objDX As DirectX8
'an instance of Direct3D (which I like to Call DirectGraphics,
'which is what it's called in the SDK)
Dim objDG As Direct3D8
'The device which will be rendering the graphic
Dim devDG As Direct3DDevice8
'A boolean to store whether or not DG was actually initialised
Dim DGInited As Boolean
'a boolean to help check if we can end the program safely
Dim ProgramExiting As Boolean
'---
'Form_Load:
'Loads when the program starts, the purpose of this subroutine
'is to call the initialisation commands and control the rendering
'loop.
'---
Private Sub Form_Load()
'Shows the Form
Me.Show
'lets the user know that D3D is initialising
Me.Caption = "Create Device: Initialising"
'Create a new, seperate existance of DirectX8
Set objDX = New DirectX8
'Call the DG init function and store it's success in a boolean
DGInited = D3DInit()
'If the initialisation failed, then end the program with an
'error message
If DGInited = False Then
MsgBox ("Critical Failure"
End
End If
'Initialisation finished, so update the title
Me.Caption = "Create Device"
'loop until the program wants to close
Do
'Clear the view port with a nice lovely blue
Call devDG.Clear(0, ByVal 0, D3DCLEAR_TARGET, &HFF0080FF, 1#, 0)
'All rendering commands must be issued within the
'.Beginscene and .EndScene commands, but rendering will be
'covered later.
devDG.BeginScene
devDG.EndScene
'The present command actually displays the backbuffer to
'the user, Note: by using a backbuffer, it stops flicker.
Call devDG.Present(ByVal 0, ByVal 0, 0, ByVal 0)
'Let the user click on the close button
DoEvents
Loop Until ProgramExiting = True
'Durh...
End
End Sub
'---
'D3DInit:
'Initialises DirectGraphics
'---
Function D3DInit() As Boolean
'Stores the current display mode (We'll use this to get the
'current pixel format for the backbuffer)
Dim udtCurrentMode As D3DDISPLAYMODE
'stores information reguarding how the image is presented to
'the user
Dim udtPParam As D3DPRESENT_PARAMETERS
'If an error occurs, go to the ErrorCheck and report an Init
'failure
On Error GoTo ErrorCheck
'Create an instance of DirectGraphics
Set objDG = objDX.Direct3DCreate
'Get the information relating to the current adaptor's mode
Call objDG.GetAdapterDisplayMode(D3DADAPTER_DEFAULT, udtCurrentMode)
With udtPParam
'The progarm will be in a window (1 = true)
.Windowed = 1
'The program will use a copy, not a flip to display
.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
'The backbuffer's pixel format will be the same as that of
'the current screen mode
.BackBufferFormat = udtCurrentMode.Format
End With
'create the device using Hardware if available, use the primary
'monitor with software vertex processing (I'll post another
'tutorial about that later...
Set devDG = objDG.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, udtPParam)
'If something went wrong out, spit out a Macintosh error and
'quit
If devDG Is Nothing Then GoTo ErrorCheck
'It was obviously successful, quit the function
D3DInit = True
Exit Function
ErrorCheck:
D3DInit = False
End Function
'---
'Form_Unload:
'Destroys objects to avoid memory leaks
'---
Private Sub Form_Unload(Cancel As Integer)
'Destroy the DirectGraphics Device
Set devDG = Nothing
'Destroy the DirectGraphics object
Set objDG = Nothing
'The program will not continue processing
ProgramExiting = True
End Sub
Sub dxf(SourceRect As Long, DestRect As Long, DestWindowOverride As Long, DirtyRegion As Long)
End Sub