Looking at the MSDN documentation, I can’t find a way to lock VertexBuffers so that I can change their data while on the device. Is this possible in XNA?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You have a number of options for modifying the contents of vertex buffers in XNA:
VertexBufferhas aSetDatamember. You can only safely use this outside ofDrawin any case where you may activate Predicated Tiling (so it’s good practice to simply always do it outside of Draw).DynamicVertexBufferis likeVertexBuffer, but faster when settings its contents. However it is susceptible to the graphics device being lost, and this condition must be handled. Also take a look atSetDataOptions.DrawUserPrimitives(and indexed version). This has the advantages of not affecting Predicated Tiling, and not causing the the command buffer to flush for small numbers of primitives.There is more information on MSDN about Dynamically Updating Vertices. And this thread on the XNA forums may also be worth reading.