Sign in to follow this  
fkhan

[SlimDX] Failed to lock driver vertex buffer when loading models

Recommended Posts

I can't figure out why the app is having trouble locking the vertexbuffer. Here is my code snippet.

[code]
// is this necessary?
if (vertexBuffer != null)
{
if (!vertexBuffer.Disposed)
{ vertexBuffer.Dispose(); }
}

vertexBuffer = new VertexBuffer(Device, VertexPositionNormalTextureColorTangent.SizeInBytes * vertexCount, Usage.WriteOnly, SlimDX.Direct3D9.VertexFormat.None, Pool.Default);

[color="#FF0000"] DataStream dataStream = vertexBuffer.Lock(0, 0, LockFlags.None);[/color] // exception is raised while attempting to lock vertexbuffer
foreach (List<VertexPositionNormalTextureColor> vlist in verticesNmTxCollst)
{
foreach (VertexPositionNormalTextureColor vertex in vlist)
{
dataStream.Write<VertexPositionNormalTextureColor>(vertex);
}
}

vertexBuffer.Unlock();[/code]

I have plenty of system memory available, this happens randomly when loading models. there are no d3d leaks or warnings showing.

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