Hi,
OK, XNA let's you set the vertex data of different streams, like so:
Device.Vertices[iStream].SetSource(vb, 0, VertexPositionColor.SizeInBytes);
I've read one use of this is where you have static geography (i.e. physical vertex location) but dynamic texture 'geography' (i.e. texture u-v offset). Or, of course, vice versa. All sounds useful, but probably a bit more advanced than where i am :-)
What i have is to "streams" of vertices - one of which is for static geography (e.g. the "world") and the other is for my dynamics stuff (e.g. the player). I have colours but no textures yet.
Each frame I'm currently going (pseudo-code):
Update()
{
update DynamicVertices
update DynamicIndices
update DynamicVertexBuffer
update DynamicIndexBuffer
if(worldHasChanged)
{
updateStaticEquivalents
}
}
Draw()
{
Device.Vertices[0].SetSource(DynamicVB) // (****)
Effect.Begin() - Draw DynamicVB - Effect.End()
Device.Vertices[0].SetSpource(StaticVB)
Effect.Begin() - Draw StaticVB - Effect.End()
}
What i'd like to do is not have to SetSource() on the static stuff each frame. It's static - so I'd like to post it to the graphics card once and leave it there. Can I do that?? I tried changing the Vertices[0] to Vertices[1] on the (****) line but that gave funny results.
- Is this workable?
- Do i have to do something fancy in the shader?
- Are there any examples?
- Is it likely to be worth the hassle???
Thanks for any advice!!
Muzz