home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / sources / chapter02 / InitDirectX / Form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  2004-10-08  |  2.1 KB  |  66 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12. Attribute VB_Name = "Form1"
  13. Attribute VB_GlobalNameSpace = False
  14. Attribute VB_Creatable = False
  15. Attribute VB_PredeclaredId = True
  16. Attribute VB_Exposed = False
  17. '---------------------------------------------------------------
  18. ' Visual Basic Game Programming for Teens
  19. ' Chapter 2 - InitDirectX program
  20. '---------------------------------------------------------------
  21. Dim dx As DirectX8
  22. Dim d3d As Direct3D8
  23. Dim d3dpp As D3DPRESENT_PARAMETERS
  24. Dim dispmode As D3DDISPLAYMODE
  25. Dim d3ddev As Direct3DDevice8
  26. Private Sub Form_Load()
  27.     'create the DirectX object
  28.     Set dx = New DirectX8
  29.     'create the Direct3D object
  30.     Set d3d = dx.Direct3DCreate()
  31.     'set the display device parameters for windowed mode
  32.     d3dpp.hDeviceWindow = Me.hWnd
  33.     d3dpp.BackBufferCount = 1
  34.     d3dpp.BackBufferWidth = 640
  35.     d3dpp.BackBufferHeight = 480
  36.     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD
  37.     d3dpp.Windowed = 1
  38.     d3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, dispmode
  39.     d3dpp.BackBufferFormat = dispmode.Format
  40.     'create the Direct3D primary device
  41.     Set d3ddev = d3d.CreateDevice( _
  42.         D3DADAPTER_DEFAULT, _
  43.         D3DDEVTYPE_HAL, _
  44.         hWnd, _
  45.         D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
  46.         d3dpp)
  47. End Sub
  48. Private Sub Form_Paint()
  49.     'clear the window with red color
  50.     d3ddev.Clear 0, ByVal 0, D3DCLEAR_TARGET, &HFF0000, 1#, 0
  51.     'refresh the window
  52.     d3ddev.Present ByVal 0, ByVal 0, 0, ByVal 0
  53. End Sub
  54. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  55.     Shutdown
  56. End Sub
  57. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  58.     If KeyCode = 27 Then Shutdown
  59. End Sub
  60. Private Sub Shutdown()
  61.     Set d3ddev = Nothing
  62.     Set d3d = Nothing
  63.     Set dx = Nothing
  64.     End
  65. End Sub
  66.