Epo
03-11-2002, 04:09 PM
I used to have a problem that my original mouse cursor flickered like crazy so I'm finally trying to make a custom mouse pointer......
Here's my code (I'll only post the important stuff):
'General Declarations
Dim DX As DirectX8
Dim D3D As Direct3D8
Dim D3DDevice As Direct3DDevice8
Dim D3DX As D3DX8
Dim textureMouse As Direct3DTexture8
Dim stripMouse(0 To 3) As TLVERTEX
'Initializing
Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmMain.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)
D3DDevice.SetVertexShader FVF
D3DDevice.SetRenderState D3DRS_LIGHTING, False
Set textureMouse = D3DX.CreateTextureFromFile(D3DDevice, App.Path & "\Mouse.bmp")
'Form Mouse Move (I'm expecting the problem to be here but I might be wrong)
stripMouse(0) = CreateTLVertex(X, Y, 0, 1, RGB(255, 255, 255), 0, 0, 0)
stripMouse(1) = CreateTLVertex(X + 16, Y, 0, 1, RGB(255, 255, 255), 0, 1, 0)
stripMouse(2) = CreateTLVertex(X, Y + 16, 0, 1, RGB(255, 255, 255), 0, 0, 1)
stripMouse(3) = CreateTLVertex(X + 16, Y + 16, 0, 1, RGB(255, 255, 255), 0, 1, 1)
'Form Load
Private Sub Form_Load()
ShowCursor 0
bRunning = InitD3D()
Me.Show
Do While bRunning
DoEvents
With D3DDevice
.BeginScene
.Clear 0, ByVal 0, D3DCLEAR_TARGET, 0, 1#, 0
.SetTexture 0, textureMouse
End With
'Mouse
D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLESTRIP, 2, stripMouse(0), Len(stripMouse(0))
With D3DDevice
.EndScene
.Present ByVal 0, ByVal 0, 0, ByVal 0
End With
Loop
UnloadD3D
Unload Me
End Sub
Posting this code, I think I just figured out the problem....It keeps drawing in the Form Load....so the Mouse Move never does anything....(once again I may be wrong) :)
Any comments or suggestions would be appreciated :) thanks
Here's my code (I'll only post the important stuff):
'General Declarations
Dim DX As DirectX8
Dim D3D As Direct3D8
Dim D3DDevice As Direct3DDevice8
Dim D3DX As D3DX8
Dim textureMouse As Direct3DTexture8
Dim stripMouse(0 To 3) As TLVERTEX
'Initializing
Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmMain.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)
D3DDevice.SetVertexShader FVF
D3DDevice.SetRenderState D3DRS_LIGHTING, False
Set textureMouse = D3DX.CreateTextureFromFile(D3DDevice, App.Path & "\Mouse.bmp")
'Form Mouse Move (I'm expecting the problem to be here but I might be wrong)
stripMouse(0) = CreateTLVertex(X, Y, 0, 1, RGB(255, 255, 255), 0, 0, 0)
stripMouse(1) = CreateTLVertex(X + 16, Y, 0, 1, RGB(255, 255, 255), 0, 1, 0)
stripMouse(2) = CreateTLVertex(X, Y + 16, 0, 1, RGB(255, 255, 255), 0, 0, 1)
stripMouse(3) = CreateTLVertex(X + 16, Y + 16, 0, 1, RGB(255, 255, 255), 0, 1, 1)
'Form Load
Private Sub Form_Load()
ShowCursor 0
bRunning = InitD3D()
Me.Show
Do While bRunning
DoEvents
With D3DDevice
.BeginScene
.Clear 0, ByVal 0, D3DCLEAR_TARGET, 0, 1#, 0
.SetTexture 0, textureMouse
End With
'Mouse
D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLESTRIP, 2, stripMouse(0), Len(stripMouse(0))
With D3DDevice
.EndScene
.Present ByVal 0, ByVal 0, 0, ByVal 0
End With
Loop
UnloadD3D
Unload Me
End Sub
Posting this code, I think I just figured out the problem....It keeps drawing in the Form Load....so the Mouse Move never does anything....(once again I may be wrong) :)
Any comments or suggestions would be appreciated :) thanks