Sign in to follow this  
TheMaskedFace

VertexBuffer Access

Recommended Posts

When I have compiled my project I get an error about Access Violation Error. I do not know the cause of this, but I think it is because of the vertexbuffer. I have a code like that.What I want to do is,just to create boundry objects of my models.
 vertexBufferBD[range] = new VertexBuffer(mesh.SourceMesh.VertexFormat.GetType(),
                                             boundryVertices.Length, modelDevice,
                                             Usage.WriteOnly,
                                             mesh.SourceMesh.VertexFormat,
                                             Pool.Default);
            vertexBufferBD[range].SetData(boundryVertices, 0, LockFlags.None);
            vertexBufferBD[range].Unlock();

          
            GraphicsStream graphicsBuffer = vertexBufferBD[range].Lock(0, 0, LockFlags.None);
            radius = Geometry.ComputeBoundingSphere(graphicsBuffer, vCount, mesh.SourceMesh.VertexFormat, out objectCenter);
                


So,does anyone help to solve my problem?I will be very happy,if so.

Share this post


Link to post
Share on other sites
At a guess, I'd say that it's because you create your vertex buffer as write only, but then read from it. Aside from that, are you sure the lock succeeds? I don't know how you test this in MDX...

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
At a guess, I'd say that it's because you create your vertex buffer as write only, but then read from it. Aside from that, are you sure the lock succeeds? I don't know how you test this in MDX...


Sounds right. In MDX, if a call fails, it would throw an exception, so at least the problem of calls "silently" failing doesn't exist :).

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