I am working on a game engine of my own and I was using Vertex buffers to create triangles and then draw textures on them. Now I want to extend it so I can do simple 2d animations using "sprite sheets". I'm not sure how to accomplish this by using vertex buffers, since those are "hard coded" and I can't figure out an easy way to draw "portions" of the sprite sheet using them. I've been searching online and most tutorials use DirectX Sprite functions to do it so my question is, is it possible to achieve this by using vertex buffers or should I go and use sprites? The only thing that is stopping me from using sprites is the fact that some graphics stuff I have already relies on vertex buffers.


If you use Dynamic Vertex Buffers in DirectX you can write to existing vertex buffers changing only one or even several attributes. You could simply overwrite the UV coordinates of vertices in the buffer of every sprite every few frames to make animations work. I think this will perform wonderful because that information needs to get to the GPU anyway and updating vertex buffers is usually very fast.

That said using the built in sprite functions might be easier but underneath a sprite is just 2 triangles and the sprite functions might even use vertex buffers underneath so if you've written a lot of code already that you don't wish to change I would recommend trying this.

(small note: creating a vertex buffer for every 'sprite' is not a good idea though, you should implement some form of sprite batching for sprites with the same texture that are on screen)

  • 4
    \$\begingroup\$ The D3DX sprite functions are just wrappers around dynamic vertex buffers - you can use PIX to confirm this. \$\endgroup\$ – Maximus Minimus Jan 3 '13 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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