Sign in to follow this  
VanillaSnake21

What size of a vertex buffer should I use?

Recommended Posts

Hi, I'm making custom text for my next game. The way I have it planned is I have a polygon per letter, and I have all the polygons stored in a vector. Probably the simplest approach, but I'm still playing around with it. I'm not too familiar with doing things right in directX, so I was wondering of how I should set up the vertex buffers. In my game I plan to have lots of text (about 1000 to 2000 chars on screen simultaneously), and I want the text to be flexible, that is so I can for example apply gravity to it and make the letters fall like blocks, or make them spin etc. Should I just have one vertex buffer and put all the letters in there? Will I still be able to apply transforms to each letter individually? Or can I make a vertex buffer per polygon? How is this usually done, btw. I need a strong emphasis on performance, so I want everything to run afap. P.S. Also forgot to mention, the text has to modifiable, searchable etc. If you have any suggestions on how to approach these kind of custom texts in general, please comment. I couldn't find anything online related to text engines, or text boxes, so I came up with this myself. Should I maybe have more then one vector, and break a text up into "words" and have a vector per word? Once again efficiency and speed is of higher priority then anything else.

Share this post


Link to post
Share on other sites
First thing worth noting is that there's no relation between the amount of data in a vertex buffer and the amount of data in a draw call. You can have a vertex buffer with 10,000 letters, and draw one at a time, offsetting into the buffer. So all you need is one dynamic buffer even if you use a lot of calls.

Regarding drawing, it's always better in terms of performance to use fewer draw calls. The typical way to achieve this is instancing. The SDK has a sample for instancing, so check the DirectX Sample Browser.

One last comment: forget performance for now. Really. You stress how important it is to you, but you don't even know if you will have a performance problem. Write code that works, that does what you want, then if it's too slow profile it to find what part is slow and improve that.

Share this post


Link to post
Share on other sites
Quote:
Original post by ET3D
First thing worth noting is that there's no relation between the amount of data in a vertex buffer and the amount of data in a draw call. You can have a vertex buffer with 10,000 letters, and draw one at a time, offsetting into the buffer. So all you need is one dynamic buffer even if you use a lot of calls.

Regarding drawing, it's always better in terms of performance to use fewer draw calls. The typical way to achieve this is instancing. The SDK has a sample for instancing, so check the DirectX Sample Browser.

One last comment: forget performance for now. Really. You stress how important it is to you, but you don't even know if you will have a performance problem. Write code that works, that does what you want, then if it's too slow profile it to find what part is slow and improve that.


Thanks for the advice. About the performance, I'm not worried too much if my code comes out slow, I just don't like programming blindfolded. I'm basically making up the next line of code as I go, which bothers me since in the end it might not all fit together as I like.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this