Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
I'm curious.... why would you want to use a struct? – Grey May 22 '13 at 23:05
because an array can't be changed once the program is compiled – user3606 May 22 '13 at 23:14
Yes it can. I'd advise learning more about programming simple things before trying to program complex things like games. – jmegaffin May 22 '13 at 23:18
ive been misinformed then – user3606 May 22 '13 at 23:21
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..." ? – Steve H May 23 '13 at 0:35
up vote 1 down vote accepted

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.

share|improve this answer

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

share|improve this answer
wanting to extend my knowledge of directx – user3606 May 23 '13 at 0:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.