Pastaspace Posted September 2, 2015 Share Posted September 2, 2015 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? Quote Link to comment Share on other sites More sharing options...
BluHornet Posted September 2, 2015 Share Posted September 2, 2015 It has been a minute since I used c++ but if I remember right there are no line breaks in a sting. If you need to break lines you need to use 2 strings. the newline character is used in cout if you are making a console program. I could remember wrong though. Quote Link to comment Share on other sites More sharing options...
beo6 Posted September 2, 2015 Share Posted September 2, 2015 have a look at this thread: http://www.leadwerks.com/werkspace/topic/12374-multiple-text-gui/page__hl__line%20break Quote Link to comment Share on other sites More sharing options...
Pastaspace Posted September 3, 2015 Author Share Posted September 3, 2015 Mmm, I know how to do multiple line stuff like that just fine, what I'm trying to do is limit the number of times I call DrawText, because it seems to significantly slow things down. Quote Link to comment Share on other sites More sharing options...
beo6 Posted September 3, 2015 Share Posted September 3, 2015 if DrawText is really slowing something down there is definetly something else wrong. Why should writing text be so hardware intensive? Quote Link to comment Share on other sites More sharing options...
Pastaspace Posted September 4, 2015 Author Share Posted September 4, 2015 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. Quote Link to comment Share on other sites More sharing options...
Josh Posted September 4, 2015 Share Posted September 4, 2015 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. Quote 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 More sharing options...
Pastaspace Posted September 4, 2015 Author Share Posted September 4, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.