Sign in to follow this  
jor1980

problem writing vertexbuffer slimdx physx

Recommended Posts

Hi am trying to make one tutorial of physx in slimdx but i get en error writing the vertexbuffer: the error message saids: don´t valid operation because of the actual state of the object. here is my debug message:
[5760] Direct3D9: :====> ENTER: DLLMAIN(5117a170): Process Attach: 00001680, tid=00000b70
[5760] 
[5760] Direct3D9: :====> EXIT: DLLMAIN(5117a170): Process Attach: 00001680
[5760] 
[5760] Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
[5760] 
[5760] Direct3D9: (INFO) :======================= Hal SWVP device selected 
[5760] 
[5760] Direct3D9: (INFO) :HalDevice Driver Style b 
[5760] 
[5760] Direct3D9: :DoneExclusiveMode
[5760] 
[5760] Direct3D9: (INFO) :Using FF to PS converter 
[5760] 
[5760] Direct3D9: (WARN) :Athlon32Compiler: CPU does not meet minimum requirements 
[5760] 
[5760] Direct3D9: (INFO) :Using P4 PSGP 
[5760] 
[5760] Direct3D9: (INFO) :Using FF to VS converter in software vertex processing 
[5760] 
[5760] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 6.96009e-316f.  This is ok. 

and here the function where i create the verxtexbuffer:
Protected Overloads Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

        device.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, Color.Black.ToArgb, 1.0F, 0)

        Dim debugrenderables As DebugRenderable = gscene.GetDebugRenderable


        Dim triangles As DebugTriangle() = debugrenderables.GetDebugTriangles
        Dim Points As DebugPoint() = debugrenderables.GetDebugPoints
        Dim lines As DebugLine() = debugrenderables.GetDebugLines

        Dim Vb As VertexBuffer = New VertexBuffer(device, lines.Length * 2 * 16, Usage.WriteOnly, VertexFormat.Position Or VertexFormat.Diffuse, Pool.Managed)


        Dim vertices As MyOwnVertexFormat() = New MyOwnVertexFormat((lines.Length * 2) - 1) {}

        For i = 0 To lines.Length - 1
            vertices((i * 2)) = New MyOwnVertexFormat(lines(i).Point0, Color.Lime)

            vertices((i * 2) + 1) = New MyOwnVertexFormat(lines(i).Point1, Color.Lime)

        Next

        Dim datStre As DataStream = Vb.Lock(0, 0, LockFlags.None)
        datStre.WriteRange(vertices)
        Vb.Unlock()



        device.BeginScene()

        device.SetStreamSource(0, Vb, 0, 16)

        device.DrawPrimitives(PrimitiveType.LineList, 0, 30)

        device.EndScene()
        device.Present()

        Me.Invalidate()
    End Sub

Share this post


Link to post
Share on other sites
The list of debug output you've provided doesn't contain any errors. It looks like the error you're getting is from your IDE, rather than DirectX, which line does your code break on, and can you post the actual error?

You shouldn't be creating a vertex buffer each frame. You should use a dynamic one and lock it each frame.

In addition, rather than using the debug renderables to debug/visualise your PhysX simulation, I would recommend using the PhysX Visual Debugger instead.

Share this post


Link to post
Share on other sites
The error is in line: datStre.WriteRange(vertices)

and it says: InvalidOperationException don´t valid operation because of the actual state of the object.

Share this post


Link to post
Share on other sites
Quote:
Original post by jor1980
The error is in line: datStre.WriteRange(vertices)

and it says: InvalidOperationException don´t valid operation because of the actual state of the object.


it is an innerexception it seems that something strange happens with the array vertices.Any clue?

Share this post


Link to post
Share on other sites
I have seen another thing that could be a clue:

look at this error lines:

Ir a: saltar código 'SlimDX.Direct3D9.VertexBuffer.Lock' no definido por el usuario
Ir a: saltar código 'SlimDX.Direct3D9.VertexBuffer.Lock' no definido por el usuario
Ir a: saltar código 'SlimDX.DataStream.WriteRange<TutoPhys.MyOwnVertexFormat>' no definido por el usuario
Excepción del tipo 'System.InvalidOperationException' en SlimDX.dll



it seems that doesn´t recognize vertexbuffer.lock it says that SlimDX.Direct3D9.VertexBuffer.Lock is not defined by the user, i don´t understand what happen.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this