Sign in to follow this  
Prads

Updating Texture Regularly

Recommended Posts

Prads    139
Ok, I need to create a IDirect3dTexture9 that I have lock in every frame and update it. I have never done this before so I just wanted to know how to do it properly. Should I create a texture, lock it in every frame, unlock it and then render it? Can you give me a small example or article? Thanks!

Share this post


Link to post
Share on other sites
gsamour    140
That sounds about right...

Just to confirm... you create the texture once, then every frame:

1. Lock it
2. Update it
3. Unlock it
4. Bind it to render with it

just out of curiosity, what kind of updates are you doing to your texture?

Share this post


Link to post
Share on other sites
Prads    139
I want to update the color of each pixel. For example if the texture is 256 by 256, the program will update the color of texture at certain interval and when it's finished updating all 256*256 pixels, it will render it.

Share this post


Link to post
Share on other sites
MJP    19754
If you need to update a texture very frame, make sure you create it with D3DUSAGE_DYNAMIC. Then when you update it every frame, lock it with D3DLOCK_DISCARD and fill in the entire contents of the texture. Doing this allows the driver to optimize the resource so that updating it doesn't cause synchronization and stalling.

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