Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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)

share|improve this answer
4  
The D3DX sprite functions are just wrappers around dynamic vertex buffers - you can use PIX to confirm this. –  Jimmy Shelter Jan 3 '13 at 10:15
add comment

Your Answer

 
discard

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.