VB Code:
  1. '// Initialise : This procedure kick starts the whole process.
  2. '// It'll return true for success, false if there was an error.
  3. Public Function Initialise() as Boolean
  4. On Error Goto ErrHandler:
  5.  
  6. Dim DispMode as D3DDISPLAYMODE '//Describes our Display Mode
  7. Dim D3DWindow as D3DPRESENT_PARAMETERS '//Describes our Viewport
  8.  
  9. Set Dx = New DirectX8 '//Create our Master Object
  10. Set D3D = Dx.Direct3DCreate() '//Make our Master Object create the Direct3D Interface
  11.  
  12. D3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DispMode '//Retrieve the current display Mode
  13.  
  14. D3DWindow.Windowed = 1 '//Tell it we're using Windowed Mode
  15. D3DWindow.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC '//We'll refresh when the monitor does
  16. D3DWindow.BackBufferFormat = DispMode.Format '//We'll use the format we just retrieved...
  17.  
  18. '//This line will be explained in detail in a minute...
  19. Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, FrmMain.Hwnd, _
  20.                                                      _ D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
  21.                                                      _ D3DWindow)
  22.  
  23. Initialise = True '//We succeeded
  24. Exit Function
  25. ErrHandler:
  26. '//We failed; for now we wont worry about why.
  27. Initialise = False
  28. End Function

This code should work with DirectX 8.1 but ther's still a little
problem left:

D3DADAPTER_DEFAULT is not found anywhere in the DirectX libary.

Mybe this code was written for 8.0?

What can I use instead of D3DADAPTER_DEFAULT?

Any ideas?

thx!