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

Started by
1 comment, last by grady 21 years, 5 months ago
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?
----------------------------www.physicsforums.comwww.opengl.org
Advertisement
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

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

That helps alot, thank you.
----------------------------www.physicsforums.comwww.opengl.org

This topic is closed to new replies.

Advertisement