D3D MouseMove

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?

Squirm
03-24-2002, 05:18 PM
Try reversing the order of the vertices, like so:

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, Y - 20, 0, 1, RGB(255, 0, 0), 0, 0, 0)
TriStrip(2) = CreateTLVertex(X - 20, Y, 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

Epo
03-24-2002, 05:27 PM
Nope....still not :(

Maybe the form isn't registering the mouse move.....I'll try to print font on the screen based on the X, Y position and see if that does anything....

Epo
03-24-2002, 05:30 PM
Well that theory was wrong.....I made a msgbox pop up on mousemove and it worked.....(although the msgbox appeared behind the form)........and if the MouseClick works (for exiting) then why wouldn't MouseMove eh? :)

:(

Epo
03-24-2002, 05:48 PM
Here's a copy of what I have if anybody wants to take a look

if so...can you tell me a few things?

1. Does the mouse flicker when you move it?
2. Is there a colorful square following the mouse?

THE RESOLUTION is set HIGH (1280 x 1024) so some of you might want to change the code depending on what you're video card/monitor can handle....

Squirm
03-25-2002, 07:19 AM
Very simple, change the ScaleMode of the form to Pixels, and it works.

:D

Epo
03-25-2002, 02:45 PM
I see why that would work :) But :( It doesn't :(

It makes perfect sense and I really don't get why it won't work on my computer....but the square still does not show up....is that the only thing you changed? (I'm going crazy)

Squirm
03-25-2002, 03:58 PM
Uhm, maybe this small change as well, you had all your vertices messed up:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Square that follows mouse
TriStrip(0) = CreateTLVertex(X - 20, Y - 20, 0, 1, RGB(255, 255, 255), 0, 0, 0)
TriStrip(1) = CreateTLVertex(X, Y - 20, 0, 1, RGB(255, 0, 0), 0, 0, 0)
TriStrip(2) = CreateTLVertex(X - 20, Y, 0, 1, RGB(0, 255, 0), 0, 0, 0)
TriStrip(3) = CreateTLVertex(X, Y, 0, 1, RGB(0, 0, 255), 0, 0, 0)
End Sub


Although the scalemode thing is equally important.

:)

Epo
03-25-2002, 08:05 PM
WOOHOO! AFTER SO LONG! FINALLY! SQUIRM YOU'RE MY HERO! :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum