Custom Mouse

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

Epo
03-19-2002, 03:48 PM
Just ignore the above message :)

could someone give me some pointers in how to create a custom mouse?....I've drawn a bitmap of the texture I want...I know how to create Vertexes.....I'm using a triangle strip.....thanks for the help :)

Squirm
03-19-2002, 04:05 PM
DirectX 4 VB Lesson 4 (http://64.23.12.52//Tutorials/DirectX8/GR_Lesson04.asp) has a bit of info about transparencies, and in the example project to download, a custom mouse pointer.

:)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum