Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ideas about a chat system.
#14
A fixed-length array would probably be best. If people want a largest history of text you could easily have it in the settings. An array of the last 100-300 lines of text shouldn't be too much of a problem though. A circular buffer like Dave mentioned would be fastest for appending new messages but even just moving every message then adding the new one should perform just fine for this. The only thing that is going to be any noticeable performance hit is the text rendering itself, especially doing two renders per character like you're doing. Rendering system fonts has always been very slow for games. You could easily increase the speed quite a lot by using custom bitmap fonts along with that will give you more flexibility in the font displays, though of course comes with a price of complexity. It can be optimized even farther by creating a vertex buffer of the visible font so you can render the whole chatbox in just one batch call and only have to update it whenever the position or text changes.

Dave Wrote:If you had a circular buffer to store messages in, you would be quicker because you would never have to reallocate memory.

Just to nit-pick, this technically wouldn't be true unless you used a fixed memory allocation per element which variable-length strings. You're still allocating the memory for the new string, you're just not having to alter the rest of the buffer except for the one discarded element. Big Grin
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)