Epo
03-24-2002, 02:33 PM
'General Declarations
Const FVF = D3DFVF_XYZRHW Or D3DFVF_TEX1 Or D3DFVF_DIFFUSE Or D3DFVF_SPECULAR
Dim DX As DirectX8
Dim D3D As Direct3D8
Dim D3DDevice As Direct3DDevice8
Dim bRunning As Boolean
Private Type TLVERTEX
X As Single
Y As Single
Z As Single
rhw As Single
color As Long
specular As Long
tu As Single
tv As Single
End Type
Dim TriStrip(0 To 3) As TLVERTEX
Dim TriList(0 To 5) As TLVERTEX
Dim TriFan(0 To 5) As TLVERTEX
Private Function CreateTLVertex(X As Single, Y As Single, Z As Single, rhw As Single, color As Long, specular As Long, tu As Single, tv As Single) As TLVERTEX
CreateTLVertex.X = X
CreateTLVertex.Y = Y
CreateTLVertex.Z = Z
CreateTLVertex.rhw = rhw
CreateTLVertex.color = color
CreateTLVertex.specular = specular
CreateTLVertex.tu = tu
CreateTLVertex.tv = tv
End Function
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Square that follows mouse
TriStrip(0) = CreateTLVertex(X, Y, 0, 1, RGB(255, 255, 255), 0, 0, 0)
TriStrip(1) = CreateTLVertex(X - 20, Y, 0, 1, RGB(255, 0, 0), 0, 0, 0)
TriStrip(2) = CreateTLVertex(X, Y - 20, 0, 1, RGB(0, 255, 0), 0, 0, 0)
TriStrip(3) = CreateTLVertex(X - 20, Y - 20, 0, 1, RGB(0, 0, 255), 0, 0, 0)
End Sub
Public Sub Render()
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H0&, 1#, 0
D3DDevice.BeginScene
'Triangle Strip
D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLESTRIP, 2, TriStrip(0), Len(TriStrip(0))
'Triangle List
D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLELIST, 2, TriList(0), Len(TriList(0))
'Triangle Fan
D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLEFAN, 4, TriFan(0), Len(TriFan(0))
D3DDevice.EndScene
D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
End Sub
That's the important stuff from my program....Render is called in my rendering loop....my problem is....the square I make in the MouseMove event does not appear on screen :(
Any ideas?
Const FVF = D3DFVF_XYZRHW Or D3DFVF_TEX1 Or D3DFVF_DIFFUSE Or D3DFVF_SPECULAR
Dim DX As DirectX8
Dim D3D As Direct3D8
Dim D3DDevice As Direct3DDevice8
Dim bRunning As Boolean
Private Type TLVERTEX
X As Single
Y As Single
Z As Single
rhw As Single
color As Long
specular As Long
tu As Single
tv As Single
End Type
Dim TriStrip(0 To 3) As TLVERTEX
Dim TriList(0 To 5) As TLVERTEX
Dim TriFan(0 To 5) As TLVERTEX
Private Function CreateTLVertex(X As Single, Y As Single, Z As Single, rhw As Single, color As Long, specular As Long, tu As Single, tv As Single) As TLVERTEX
CreateTLVertex.X = X
CreateTLVertex.Y = Y
CreateTLVertex.Z = Z
CreateTLVertex.rhw = rhw
CreateTLVertex.color = color
CreateTLVertex.specular = specular
CreateTLVertex.tu = tu
CreateTLVertex.tv = tv
End Function
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Square that follows mouse
TriStrip(0) = CreateTLVertex(X, Y, 0, 1, RGB(255, 255, 255), 0, 0, 0)
TriStrip(1) = CreateTLVertex(X - 20, Y, 0, 1, RGB(255, 0, 0), 0, 0, 0)
TriStrip(2) = CreateTLVertex(X, Y - 20, 0, 1, RGB(0, 255, 0), 0, 0, 0)
TriStrip(3) = CreateTLVertex(X - 20, Y - 20, 0, 1, RGB(0, 0, 255), 0, 0, 0)
End Sub
Public Sub Render()
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H0&, 1#, 0
D3DDevice.BeginScene
'Triangle Strip
D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLESTRIP, 2, TriStrip(0), Len(TriStrip(0))
'Triangle List
D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLELIST, 2, TriList(0), Len(TriList(0))
'Triangle Fan
D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLEFAN, 4, TriFan(0), Len(TriFan(0))
D3DDevice.EndScene
D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
End Sub
That's the important stuff from my program....Render is called in my rendering loop....my problem is....the square I make in the MouseMove event does not appear on screen :(
Any ideas?