home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 3195
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4680
- LinkTopic = "Form1"
- ScaleHeight = 3195
- ScaleWidth = 4680
- StartUpPosition = 3 'Windows Default
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '---------------------------------------------------------------
- ' Visual Basic Game Programming for Teens
- ' Chapter 2 - InitDirectX program
- '---------------------------------------------------------------
- Dim dx As DirectX8
- Dim d3d As Direct3D8
- Dim d3dpp As D3DPRESENT_PARAMETERS
- Dim dispmode As D3DDISPLAYMODE
- Dim d3ddev As Direct3DDevice8
- Private Sub Form_Load()
- 'create the DirectX object
- Set dx = New DirectX8
- 'create the Direct3D object
- Set d3d = dx.Direct3DCreate()
- 'set the display device parameters for windowed mode
- d3dpp.hDeviceWindow = Me.hWnd
- d3dpp.BackBufferCount = 1
- d3dpp.BackBufferWidth = 640
- d3dpp.BackBufferHeight = 480
- d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD
- d3dpp.Windowed = 1
- d3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, dispmode
- d3dpp.BackBufferFormat = dispmode.Format
- 'create the Direct3D primary device
- Set d3ddev = d3d.CreateDevice( _
- D3DADAPTER_DEFAULT, _
- D3DDEVTYPE_HAL, _
- hWnd, _
- D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
- d3dpp)
- End Sub
- Private Sub Form_Paint()
- 'clear the window with red color
- d3ddev.Clear 0, ByVal 0, D3DCLEAR_TARGET, &HFF0000, 1#, 0
- 'refresh the window
- d3ddev.Present ByVal 0, ByVal 0, 0, ByVal 0
- End Sub
- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
- Shutdown
- End Sub
- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
- If KeyCode = 27 Then Shutdown
- End Sub
- Private Sub Shutdown()
- Set d3ddev = Nothing
- Set d3d = Nothing
- Set dx = Nothing
- End
- End Sub
-