home *** CD-ROM | disk | FTP | other *** search
/ Microsoft DirectX SDK 7.0 / Dx7.bin / DXF / samples / multimedia / vbsamples / d3dim / src / fireworks / fireworksinit.bas < prev    next >
Encoding:
BASIC Source File  |  1999-08-17  |  2.2 KB  |  81 lines

  1. Attribute VB_Name = "FireWorksInit"
  2. ' IM7 Initialization Module
  3.  
  4. Public DX As New DirectX7
  5. Public DDraw As DirectDraw7
  6. Public D3D As Direct3D7
  7. Public DDSFront As DirectDrawSurface7
  8. Public DDSBack As DirectDrawSurface7
  9. Public DDSFrontDesc As DDSURFACEDESC2
  10. Public DDSBackDesc As DDSURFACEDESC2
  11. Public DDSCaps As DDSCAPS2
  12. Public d3ddev As Direct3DDevice7
  13. Public BackRect As RECT
  14. Public ViewPort1 As D3DVIEWPORT7
  15. Public Light1 As D3DLIGHT7
  16. Public Material1 As D3DMATERIAL7
  17. Public RWDestRect As RECT, RWSourceRect As RECT
  18. Public MatWorld1 As D3DMATRIX, matView1 As D3DMATRIX, matProj1 As D3DMATRIX
  19. Public MustExit As Boolean
  20. Public UseRGB As Boolean
  21.  
  22. Sub IM7Terminate()
  23.  
  24.     DDraw.SetCooperativeLevel FireWorksForm.hWnd, DDSCL_NORMAL
  25.     DDraw.RestoreDisplayMode
  26.     CleanUp
  27.     Set DX = Nothing
  28.     
  29.     End
  30. End Sub
  31. Sub CleanUp()
  32.     Set d3ddev = Nothing
  33.     Set D3D = Nothing
  34.     Set DDSBack = Nothing
  35.     Set DDSFront = Nothing
  36.     Set DDraw = Nothing
  37.  
  38. End Sub
  39.  
  40. Sub InitDX()
  41.     Dim c As D3DCOLORVALUE
  42.     Dim lProp As D3DLIGHT7
  43.     Dim Index As Long
  44.     Dim b As Boolean
  45.  
  46.         DoEvents
  47.         
  48.         With FireWorksForm.IMCanvas1
  49.             If .DX.SystemBpp <= 8 Then
  50.                 MsgBox "This sample was designed to run in High Color (16 bit) displays"
  51.                 End
  52.             End If
  53.             b = .StartWindowed()
  54.             If b = False Then
  55.                 MsgBox "could not initialize 3d device"
  56.                 End
  57.             End If
  58.             If False = CheckCaps(.Direct3DDevice) Then
  59.                 UseRGB = True
  60.                 b = .InitWindowed("", "IID_IDirect3DRGBDevice")
  61.             End If
  62.             If b = False Then
  63.                 MsgBox "could not initialize 3d device"
  64.                 End
  65.             End If
  66.  
  67.         End With
  68.  
  69.         FireWorksForm.Show
  70. End Sub
  71.  
  72. Function CheckCaps(d3ddev As Direct3DDevice7) As Boolean
  73.     Dim desc As D3DDEVICEDESC7
  74.     d3ddev.GetCaps desc
  75.     
  76.     If (desc.dpcTriCaps.lSrcBlendCaps And D3DPBLENDCAPS_ONE) <> D3DPBLENDCAPS_ONE Then Exit Function
  77.     If (desc.dpcTriCaps.lDestBlendCaps And D3DPBLENDCAPS_ONE) <> D3DPBLENDCAPS_ONE Then Exit Function
  78.  
  79.     CheckCaps = True
  80. End Function
  81.