So instead of using an array to hold vertices information use a struct instead. Is this possible, does the Idirect3dvertexbuffer allow it?

  • \$\begingroup\$ I'm curious.... why would you want to use a struct? \$\endgroup\$
    – Grey
    May 22, 2013 at 23:05
  • \$\begingroup\$ because an array can't be changed once the program is compiled \$\endgroup\$
    – user3606
    May 22, 2013 at 23:14
  • \$\begingroup\$ Yes it can. I'd advise learning more about programming simple things before trying to program complex things like games. \$\endgroup\$
    – jmegaffin
    May 22, 2013 at 23:18
  • \$\begingroup\$ ive been misinformed then \$\endgroup\$
    – user3606
    May 22, 2013 at 23:21
  • 1
    \$\begingroup\$ For the issue of resizing the data set, that post recommends using a std::vector instead of an array. So why isn't your question: "Can you use a std::vector instead of an array to hold..." ? \$\endgroup\$
    – Steve H
    May 23, 2013 at 0:35

2 Answers 2


Yes, you can. You can also use structs containing arrays, or arrays containing structs.

All D3D expects is a pointer to a block of data, formatted according to the specifications you provide it when you create the associated vertex declaration, and containing information of the appropriate type.

If your structures, or arrays, or whatnot provide that, then D3D will accept them regardless of the representation you chose for them in your code.


Technically, it's oblivious to whether you are using a struct or an array, it's just dealing with a pointer to a regular set of data. Structs and arrays are compiler constructs, and the DirectX logic is agnostic to the compiler that produced the data it's being fed - however I too am curious why you would use a struct - much larger chance you might get data organization messed up

  • \$\begingroup\$ wanting to extend my knowledge of directx \$\endgroup\$
    – user3606
    May 23, 2013 at 0:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .