Archived

This topic is now archived and is closed to further replies.

grady

vertices that have to change ( not as a whole )every frame

Recommended Posts

I want to draw some particles on the screen, but each one is going to fly around in its own direction. From the way you are supposed to use vertex buffers, it seems like they want to have static vertices. Can I simply keep doing the process: "transform vertices, lock, copy vertices, unlock", each frame or do I need to keep releasing and recreating the VB each frame?

Share this post


Link to post
Share on other sites
quote:
Can I simply keep doing the process: "transform vertices, lock, copy vertices, unlock", each frame


Yes. That''s exactly the way to do it.

The buffer for doing that every frame should be DYNAMIC, marked as write only and locked with DISCARD and NOOVERWRITE flags though. It''s likely (and usual) you''ll have the particles used in the particle system simulation stored in some normally allocated memory (i.e. not a VB) and then you generate the visible quads from those. Simply generate the quads direct into the buffer.

The correct usage pattern for those flags is detailed in the DirectX FAQ under the topic What''s a good usage pattern for vertex buffers if I''m generating dynamic data?

An alternative interesting idea is to use a vertex shader which can work out the position of a particle vertex based purely on a time. There''s a sample on the nVidia website showing this.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites