Jump to content

DrawText ignores newline characters?


Pastaspace
 Share

Recommended Posts

I've got a string that has a newline in it, IE something like

string s_myString = "Hello \n world.";

But I noticed that while normally said string would be output on two lines. When using DrawText, it wouldn't show the newline character, but wouldn't put the next bit of text on a new line.

Am I missing something here, or is that just a limitation of DrawText?

Link to comment
Share on other sites

I asked myself the same question, and it definitely is DrawText, nothing else in the code slows things down, and eliminating those lines speeds things back up to normal. After more than a few calls, like 8 or so, it starts to drop about 12 FPS, and then it just goes down from there.

Link to comment
Share on other sites

DrawText() tends to be fairly slow. It's doing a draw call for every single character and there is a lot of setup code for each call. If you're just displaying the FPS or printing the health it's not a big deal, but you don't want to be displaying lots of lots of text with that command. It would be a lot better to render to a texture and then draw the texture onscreen, if the text isn't changing. Of course, you've got to be drawing a lot of text before it will start to matter, so it depends on what you are doing.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Rendering text relating to dialogue, inventory, stats, general RPG stuff.

The text usually doesn't change that much while accessing these menus (there's highlighting if you mouse over it and that's about it), how would I go about rendering to a texture? Even a few frames saved is nice.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...