GPWiki.org
GPWiki.org
It is currently Fri May 24, 2013 10:41 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue May 12, 2009 4:49 pm 
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?


Top
  
 
 Post subject:
PostPosted: Thu Nov 12, 2009 8:09 pm 
i dont know if it will help someone but DirectX8 in VB .NET stores Constants with CONTS_ at the beginning so for your D3DX_DEFAULT it could be

'load surface from file
d3dx.LoadSurfaceFromFile( _
surf, _
System.IntPtr.Zero, _
filename, _
System.IntPtr.Zero, _
CONST_D3DXENUM.D3DX_DEFAULT, _
0, _
System.IntPtr.Zero)

hope i helped


Top
  
 
 Post subject:
PostPosted: Wed Nov 18, 2009 7:40 am 
Level 1 Cleric

Joined: Fri Feb 22, 2008 7:10 pm
Posts: 10
You should consider switching to using DirectX 9 and SlimDX instead of the antiquated DirectX8.

_________________
Cross platform C# game development
http://www.agatelib.org/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group