Re: DirectX is too slow
- From: "Galen Somerville" <galen@xxxxxxxxxxxxxxxx>
- Date: Wed, 6 Jun 2007 12:29:02 -0700
"Galen Somerville" <galen@xxxxxxxxxxxxxxxx> wrote in message
news:umnEQlMoHHA.1220@xxxxxxxxxxxxxxxxxxxxxxx
For those wondering what I mean by slow, download the attachment and see
the difference.
Pardon the huge binary. In the zip file is ctlPictDraw.dll (managed
DirectX), TestPictDraw.exe (VB2005 using the dll) and lastly TestDraw.exe
(VB6 standalone)
Both exe's do the same job !!!!!
Galen
"Galen Somerville" <galen@xxxxxxxxxxxxxxxx> wrote in message
news:ewjU7ZIoHHA.716@xxxxxxxxxxxxxxxxxxxxxxx
I have a dll for the DirectX drawing routines. I use
PrimitiveType.LineStrip
to draw six lines at a time (real time data will arrive in groups of 6).
I use QueryPerformanceCounter to time how long it takes to draw 6 lines.
I
can redraw over and over by hitting a Button.
The minimum time is about 15 milliseconds, maximum about 30 ms and the
average around 20 ms. This is unacceptably slow for my use.
Does anyone see anything in the code below that could be causing this
timing
problem??
Not shown is setting up SoundsAry with a continuous triangle wave for
display.
HERE'S THE MAIN PROGRAM LOOP DRAWING 1019 LINES IN GROUPS OF 6
PictDraw1.PictMode = 6 'vertices
ArgX1 = 0
Count = 0
For Index = 0 To 169
If Index = 33 Then QueryPerformanceCounter(Ctr1)
For Inner = 0 To 5
ArgY1(Inner) = SoundsAry(Count)
Count = Count + 1
Next
PictDraw1.DoVerts(ArgX1, ArgY1, Color.Black)
ArgX1 = ArgX1 + 6
If Index = 33 Then QueryPerformanceCounter(Ctr2)
If Index = 35 Then
QueryPerformanceFrequency(Freq)
Label1.Text = CStr((Ctr2 - Ctr1) / Freq)
Label1.Refresh()
End If
Next
HERES THE DLL ROUTINE SETTING UP THE DIRECTX
Public Property PictMode() As Integer
Get
Return Mode
End Get
Set(ByVal value As Integer)
Dim Index As Short
Mode = value '0= not sweeps 1 up=maximum number of
vertices
If Mode <> 0 Then
Skipflg = False
Panel1.Visible = False
Dim d3dpp As PresentParameters = New PresentParameters()
d3dpp.SwapEffect = SwapEffect.Discard
d3dpp.Windowed = True
d3dDevice = New Device(0, DeviceType.Hardware, Me, _
CreateFlags.SoftwareVertexProcessing, d3dpp)
VerBuf = New
VertexBuffer(GetType(CustomVertex.TransformedColored), Mode, _
d3dDevice, Usage.Dynamic Or Usage.WriteOnly,
CustomVertex.TransformedColored.Format, _
Pool.Default)
d3dDevice.Clear(ClearFlags.Target, Me.BackColor, 1.0F, 0)
d3dDevice.RenderState.Lighting = False
NumVerts = Mode
ReDim Verts(Mode - 1)
For Index = 0 To NumVerts - 1
Verts(Index).Z = 0.5F
Verts(Index).Rhw = 1
Next Index
Else
HERE'S THE DLL ROUTINE DRAWING LINES 6 AT A TIME.
Public Sub DoVerts(ByVal X1 As Integer, ByVal Y1() As Short, ByVal
Value
As Color)
Dim Index As Short
Verts(0).X = X1
Verts(0).Y = Y1(0)
Verts(0).Color = Value.ToArgb
X1 = X1 + 1
For Index = 1 To NumVerts - 1
Verts(Index).X = X1
Verts(Index).Y = Y1(Index)
Verts(Index).Color = Value.ToArgb
X1 = X1 + 1
Next Index
Strm = VerBuf.Lock(0, 0, 0)
' Strm.Position = 0
Strm.Write(Verts)
VerBuf.Unlock()
d3dDevice.BeginScene()
d3dDevice.VertexFormat = CustomVertex.TransformedColored.Format
d3dDevice.SetStreamSource(0, VerBuf, 0)
d3dDevice.DrawPrimitives(PrimitiveType.LineStrip, 0, NumVerts - 1)
d3dDevice.EndScene()
d3dDevice.Present()
End Sub
Galen
Sarcasm
Thanks for the help
/Sarcasm
Galen
.
- Follow-Ups:
- Re: DirectX is too slow
- From: ZMan
- Re: DirectX is too slow
- Prev by Date: Re: "AccessViolationException" on Mesh.Intersect function
- Next by Date: Re: DirectX is too slow
- Previous by thread: Re: "AccessViolationException" on Mesh.Intersect function
- Next by thread: Re: DirectX is too slow
- Index(es):
Relevant Pages
|