Sign in to follow this  
jdub

Why can't I lock this texture?

Recommended Posts

jdub    459
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?

[b]Texture Creation:[/b]
[code]

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


[b]Texture Updating:[/b]
[code]

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++;
}
[/code]

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