Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8234143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:22:43+00:00 2026-06-07T18:22:43+00:00

I am writing an application that needs to adapt to various potential vertex formats.

  • 0

I am writing an application that needs to adapt to various potential vertex formats. The meshes I am loading may or may not have any number of potential vertex attribts (color, normals, texturecoords, weights, and so on).

A simple example of a declaration looks like this:

D3DVERTEXELEMENT9 simple_decl[] =
{
    {0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
    {0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,   0},
    {0, 20, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR,   0},
    {0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,   1},
    D3DDECL_END()
};


struct MYVERTS
{   
    float x,y,z,u,v;
    DWORD colr;
    float nx,ny,nz;
};

Basically a D3DVERTEXELEMENT9 is an array of offsets. Each offset being the size of the data memebers of “MYVERTS”.

If the user exports a model with just XYZ coordinates and color then i want to dynamically generate a struct with 3 floats and 1 dword and then generate a declaration with offsets and D3DDECLUSAGE.

I have no clue how to do this. Does anyone have any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:22:45+00:00Added an answer on June 7, 2026 at 6:22 pm

    You won’t be able to “dynamically generate a struct”, but you can start by filling in your own D3DVERTEXELEMENT9 array. A simple method is to parse the user model for the components and types that it’s using and push_back() into a std::vector<D3DVERTEXELEMENT9>.

    After you’ve parsed all components from the model, you can calculate the offsets for each component (the second column of numbers in your example). You’ll need to calculate another “offset” from the final component to the start of the next, and this becomes your vertex stride. In your example it’s 24, plus the size of D3DDECLTYPE_FLOAT3 or 12, for a vertex stride of 36.

    Once you have the offsets and the stride, you can write the vertex data from the user model into the correct bytes in your vertex buffer.

    You can even pass the contents of the vector to D3D after pushing in the D3DDECL_END().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a Java Swing application that needs to have a window receive
I have a user level application that needs to enable/disable a device by writing
I'm writing an application that needs to uncompress data compressed by another application (which
I am writing an iPhone application that needs to record audio from the built-in
I am writing a Facebook application that needs to post on a friend's wall
I'm writing an application in C# that needs to decrypt some data that was
I'm writing a windows service application that needs to serialize and deserialize XML documents
I am writing a .NET WinForms application that needs to display a list of
I am writing an Adobe AIR application that needs to build in a CI
I am writing a java application that takes schema-bounded XML as input and needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.