Problem rendering an animated mesh (vb.net)

I'm trying to render an animated mesh (tiny.x), I have translated the c# sample code to vb.net but when it gets to the DrawSubset method it throws an error:
-Run-time exception thrown : System.AccessViolationException.

I have realized that it happens an earlier error when trying to set the Device.RenderState.VertexBlend property.
The exception is:
-ErrorString:"D3DERR_INVALIDCALL"

I'm including the device intialization:


Dim DispMode As DisplayMode
DispMode = Manager.Adapters(Manager.Adapters.Default.Adapter).CurrentDisplayMode
' Define the presentation parameters
Params = New PresentParameters()
Params.Windowed = True
Params.SwapEffect = SwapEffect.Discard
Params.AutoDepthStencilFormat = DepthFormat.D16
Params.EnableAutoDepthStencil = True

Dim adapterOrdinal As Integer = Manager.Adapters.Default.Adapter
Dim flags As CreateFlags = CreateFlags.SoftwareVertexProcessing

Dim capacidad As Caps = Manager.GetDeviceCaps(adapterOrdinal, DeviceType.Hardware)

If capacidad.MaxVertexBlendMatrices >= 4 Then
flags = CreateFlags.HardwareVertexProcessing
If capacidad.DeviceCaps.SupportsHardwareTransformAndLight Then
flags = CreateFlags.HardwareVertexProcessing
End If
If capacidad.DeviceCaps.SupportsPureDevice Then
flags = flags Or CreateFlags.PureDevice
End If
Else
flags = CreateFlags.SoftwareVertexProcessing
End If

' Try to create the device
Try
xoDevice = New Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, Me, flags, Params)

' Define which type of vertex will be used
xoDevice.VertexFormat = VertexParams
...



Does anyone know what can be happening
Thank you so much in advance for any comments


Answer this question

Problem rendering an animated mesh (vb.net)

  • -JFo

    Thank you for your answer, but i forgot to post that i had found the problem, i had to set the eventhandlers of the device to false in order to be able to execute the sample.
  • adfm

    You can find converted VB samples here: http://www.thezbuffer.com/articles/315.aspx



  • Problem rendering an animated mesh (vb.net)