Jump to content
  • Advertisement


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


When allocating length for a vertex buffer...

This topic is 5423 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

If your vertex''s size doesn''t fit to 8 bytes without padding, aren''t you wasting space for every vertex? I am saying this becuase class objects are usually padded to 8 bytes.

Share this post

Link to post
Share on other sites
The default rules for padding a struct or class is to look at the size of the data type of largest member, and ensure that the structure is aligned to the size of that data type.

The largest member of a D3D vertex would be 4 bytes since all of the components are either floats or D3DCOLORs (DWORDs). The class or struct would then be aligned on a 4-byte address by the compiler. Since every member of the vertex is also 4-byte aligned, there would never need to be any padding added by the compiler in an array of vertices (i.e. from a vertex buffer).

See the section in the VS.Net docs on Structure Alignment.

Share this post

Link to post
Share on other sites
Thanks for clearing that up.

I don't mean to spam, but I have another quick question.

EDIT: Don't answer it.

According to MSDN, when creating a vertex buffer, you cannot use the D3DUSAGE flag D3DUSAGE_DYNAMIC with the D3DPOOL flag D3DPOOL_MANAGED.

I am only creating one vertex buffer for my whole program, and since I am purely drawing sprites along with the RHW flag in my FVF, I need to make make it dynamic. Here is where my question comes in: because I can't make it managed, should I make use the D3DPOOL_DEFAULT flag? If so, I assume I would have to reset the device if it is lost.

[edited by - PlayGGY on January 11, 2004 8:44:31 PM]

[edited by - PlayGGY on January 11, 2004 9:05:32 PM]

[edited by - PlayGGY on January 11, 2004 10:35:05 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!