Why can't I lock this texture?

Started by
1 comment, last by jdub 13 years ago
Every frame, I lock a texture, discarding its contents and generating a different texture. However, after the first frame of locking and generating the texture, when I go to lock it again, directX throws a fit. P.S. Code is in C#/SlimDX(dx wrapper) but should look very similar to how it looks in directX. What's wrong here?

Texture Creation:


this.frame = new Texture(game.DeviceManager.Device,
size.Width,
size.Height,
1,
Usage.Dynamic,
Format.A8R8G8B8,
Pool.Default
);



Texture Updating:


private void generateFrame()
{
byte[] buffer = new byte[size.Width * size.Height * 4];
DataRectangle data = this.frame.LockRectangle(0, LockFlags.Discard);
buffer = PerlinNoise3D.CreateSurfaceA8R8G8B8(this.size.Width,
this.size.Height,
z );
data.Data.Write(buffer, 0, buffer.Length);
z++;
}
J.W.
Advertisement
You should call the UnlockRectangle method after you are finished with the locked rectangle!
Wow.... I can't believe I forgot about that X/ thanks haha
J.W.

This topic is closed to new replies.

Advertisement