📄 mdx8a.bas
字号:
Attribute VB_Name = "mdx8a"
'parte grafica
Global dx As New DirectX8
Global D3DX As New D3DX8
'////////////////////////////////
'//////PARTE GRAFICA////////////
'//////////////////////////////
Global D3D As Direct3D8 'direct 3d
Global device As Direct3DDevice8 'spazio in cui si rappresenta
Global dSprite As D3DXSprite 'gestisce gli sprite
Global matWorld As D3DMATRIX 'rappresenta il mondo
Global matView As D3DMATRIX 'rappresenta la camera
Global matProj As D3DMATRIX 'rappresenta come la camera rappresenta il mondo
Global Const rad1 = 3.14 / 180 'il pi greco
Global D3DWindow As D3DPRESENT_PARAMETERS 'descrive i parametri
Global rFinestra As RECT 'dimensione della finestra
'rappresenta un oggetto di tipo X
Type oggX
numX As Long
meshX As D3DXMesh
mateX() As D3DMATERIAL8
texX() As Direct3DTexture8
End Type
'rappresenta un oggetto di tipo x avanzato(risparmio texture)
Type oggX2
numX As Long
meshX As D3DXMesh
mateX() As D3DMATERIAL8
texX() As Long 'riferimento all'array di texture
End Type
Global textureArray() As Direct3DTexture8
Global stringArray() As String
'per le trasformazioni matriciali
Global CosRx As Single
Global CosRy As Single
Global CosRz As Single
Global SinRx As Single
Global SinRy As Single
Global SinRz As Single
Global mat1 As D3DMATRIX
'////////////////////////
'//PARTE AUDIO//////////
'//////////////////////
'wave
Global DS As DirectSound8 'gestisce il direct sound
'wave capture
Global dsc As DirectSoundCapture8
Global dscb As DirectSoundCaptureBuffer8
Global dscd As DSCBUFFERDESC
Global capFormat As WAVEFORMATEX
'midi
Global dml As DirectMusicLoader8
Global dmp As DirectMusicPerformance8
Global seg As DirectMusicSegment8
'////////////////////////
'//parte dei controlli//
'//////////////////////
Global DI As DirectInput8
'tastiera
Global tastieraX As DirectInputDevice8
Global tastiX As DIKEYBOARDSTATE
'mouse
Global topoX As DirectInputDevice8
Global mouseX As DIMOUSESTATE
'joy
Global mito As DirectInputDevice8
Global pulsanti As DIJOYSTATE
Global presente As Boolean
'joy2
Global mito2 As DirectInputDevice8
Global pulsanti2 As DIJOYSTATE
Global presente2 As Boolean
'parte internet
'API
'Public Declare Function GetTickCount Lib "kernel32" () As Long
Public Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, ByRef RECT As RECT) As Long
'
'//////////////////////////
'//CREA LA GRAFICA////////
'////////////////////////
Sub creaSchermo(dxWidth As Long, dxHeight As Long, dxBpp As CONST_D3DFORMAT, Fhwnd As Long, finestra As Boolean, numBackBuffer As Long, Optional debugMode As Boolean)
Dim DispMode As D3DDISPLAYMODE 'descrive il display
'
Set D3D = dx.Direct3DCreate() 'crea D3d
'ottiene il presente stato
D3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DispMode
'dimensione finestra
GetWindowRect Fhwnd, rFinestra
'crea tutto
If finestra Then
'inizializza finestra
D3DWindow.Windowed = 1
D3DWindow.BackBufferCount = 1 '1 backbuffer
D3DWindow.BackBufferFormat = DispMode.Format 'colore
Else
'inizializza schermo pieno
D3DWindow.BackBufferCount = numBackBuffer ' backbuffer
D3DWindow.BackBufferFormat = dxBpp 'colore
D3DWindow.BackBufferWidth = dxWidth
D3DWindow.BackBufferHeight = dxHeight
End If
'comuni
D3DWindow.SwapEffect = D3DSWAPEFFECT_FLIP
D3DWindow.EnableAutoDepthStencil = 1
D3DWindow.AutoDepthStencilFormat = D3DFMT_D16 '16 bit Z-Buffer
D3DWindow.hDeviceWindow = Fhwnd 'target
If debugMode Then D3DWindow.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE
'crea device
Set device = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Fhwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)
Set dSprite = D3DX.CreateSprite(device)
End Sub
Sub iniziaTutto()
'Regola un mio standard
'setta il tipo di vertice
'device.SetVertexShader D3DFVF_VERTEX Or D3DFVF_TEX1
'disattiva la luce
device.SetRenderState D3DRS_LIGHTING, 0
device.SetRenderState D3DRS_SHADEMODE, D3DSHADE_GOURAUD
'attiva lo z buffer
device.SetRenderState D3DRS_ZENABLE, 1
'qualit
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -