Sign in to follow this  

Change values of VB during Rendering

This topic is 3596 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys! Short question: I initialized VB and IB, but wan't to change the values of the VertexBuffer during the rendering process. Can anyone tell me how I can get access to the VB values? Thanks, enne

Share this post


Link to post
Share on other sites
Quote:
Original post by enne87
Hi guys!

Short question: I initialized VB and IB, but wan't to change the values of the VertexBuffer during the rendering process.
Can anyone tell me how I can get access to the VB values?
Lock the vertex buffer and cast the returned pointer to your vertex type. Then modify the vertices and unlock the VB.

Look at almost any of the SDK samples for code on how to do this.

If you're updating the VB frequently (Once every frame or so), then it should be created as dynamic.

This is all assuming DX9 and C++, if you're using something else you'll have to say what it is.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by enne87
Hi guys!

Short question: I initialized VB and IB, but wan't to change the values of the VertexBuffer during the rendering process.
Can anyone tell me how I can get access to the VB values?
Lock the vertex buffer and cast the returned pointer to your vertex type. Then modify the vertices and unlock the VB.

Look at almost any of the SDK samples for code on how to do this.

If you're updating the VB frequently (Once every frame or so), then it should be created as dynamic.

This is all assuming DX9 and C++, if you're using something else you'll have to say what it is.


Thanks much, actually I'm using C#, but it shouldn't be too complicated to lock the VB anyway.

Again thanks :)

Cheers,

enne

Share this post


Link to post
Share on other sites
Quote:
Original post by enne87
Let's say I want to use a dynamic VB, which CreateFlags - attribute should I use to initialize my device?
The documentation should tell you. In C++, it's D3DCREATE_DYNAMIC, in C# it's probably something like CreateFlags.Dynamic.

Share this post


Link to post
Share on other sites
One last question: Is it possible to change the vertex count during the rendering process or do I have to initialize a new vertexbuffer object as soon as the vertex number of my 3D object changes?

Share this post


Link to post
Share on other sites
Quote:
Original post by enne87
One last question: Is it possible to change the vertex count during the rendering process or do I have to initialize a new vertexbuffer object as soon as the vertex number of my 3D object changes?
The vertex buffer needs to be a fixed size, but you could create a VB big enough for 1000 vertices, and only use 500. Then lock it and put 1000 vertices in.

If you need to resize the VB itself, you'll have to re-create it.

Share this post


Link to post
Share on other sites

This topic is 3596 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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