Hello everyone! This is my first post on your forum but I have used it many times before for tutorials and help with projects.
For my programming class my senior project is to make a simple game. BUT. I'm still a complete newbie and until I can figure out this confusing mess of a book I can't make my game. The book appears to be in VB6 and I am using VB9. Below is the section of code that I am having trouble with.
Code:
Private Sub AddBitmap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Set up the main form
Me.Width = SCREENWIDTH + 12
Me.Height = SCREENHEIGHT + 30
'Inittialize Direct3D
InitDirect3D(Me.Handle, SCREENWIDTH, SCREENHEIGHT, FULLSCREEN)
'Get reference to the back bugger
backbuffer = d3ddev.GetBackBuffer(0, CONST_D3DBACKBUFFERTYPE.D3DBACKBUFFER_TYPE_MONO)
'Load the bitmap file
surface = LoadSurface(My.Computer.FileSystem.CurrentDirectory & "\sky.bmp")
End Sub
Private Function LoadSurface(ByRef filename As String) As Direct3DSurface8
On Error GoTo fatal_error
Dim surf As Direct3DSurface8
'return error by default
LoadSurface = Nothing
'create the new surface
surf = d3ddev.CreateImageSurface(SCREENWIDTH, SCREENHEIGHT, dispmode.Format)
If surf Is Nothing Then
MsgBox("Error creating surface!")
Exit Function
End If
'load surface from file
d3dx.LoadSurfaceFromFile( _
surf, _
System.IntPtr.Zero, _
filename, _
System.IntPtr.Zero, _
D3DX_DEFAULT, _
0, _
System.IntPtr.Zero)
If surf Is Nothing Then
MsgBox("Error loading " & filename & "!")
Exit Function
End If
'return the new surface
LoadSurface = surf
fatal_error:
Exit Function
The problem code is where is loads the surface from file:
Code:
'load surface from file
d3dx.LoadSurfaceFromFile( _
surf, _
System.IntPtr.Zero, _
filename, _
System.IntPtr.Zero, _
D3DX_DEFAULT, _
0, _
System.IntPtr.Zero)
The book said to use
ByVal 0 in place of where I have
System.IntPtr.Zero. But I got an error by doing that and noticed in one of the couple projects I downloaded (and converted) that they used
System.IntPtr.Zero in similar places. The book also says to use
D3DX_DEFAULT which I am guessing is some sort of constant or something. I've searched but can't find anything to replace it with as VB9 gives me an error "Name 'D3DX_DEFAULT' is not declared." I've been following the book to the letter (mostly...) and I've searched the book (it's a .PDF) and can not find any reference to this before.
Please help. What can I replace that with?