Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Drawing floating text, draw text all the time, or draw to render texture?  (Read 2117 times)

0 Members and 1 Guest are viewing this topic.

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Hello.
I am making : http://en.sfml-dev.org/forums/index.php?topic=14563.0
Working on conversation between units, i want to make floating text that will be used for:
"Long text ~30 to 100char", "battle numbers(heal,damage,effect, battle shouts)", "Hints", "NPC conversation and player to npc conversation".
So to assume there should be 500char worth of text on screen at a same time(at specific time not alwais), i was wondering if anybody did testing with sf::Text to render texture to render window or sf::Text to render window?

And generally to ask, any better ideas then just doing sf::Text and drawing at location?
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
If you are rendering the exact same block of text (as in same colour, size, font etc.) over and over again then pre-rendering them to an sf::RenderTexture and just using an sf::Sprite to display the whole block of text will probably be faster. Just remember to copy the texture data out of the sf::RenderTexture into a "normal" sf::Texture so you can get rid of it (it is a very heavy resource) when you are done baking all of your text.

This can be considered a time-memory trade-off. You are trading drawing time for graphics memory. The more such text blocks you pre-bake the more drawing time you will save, but the more graphics memory it will cost to run your application. SFGUI uses a similar strategy, but caches the whole screen in a raw FBO which leads to a significant performance increase when compared to normally rendering a large number of GUI elements (including text).
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
EDIT:: i never thanked you for the knowledge, thank you!

Humm... a efficient way would be to have a sf::Texture intro which i want to draw text on, then from there i use sf::VertexArray to get texture coordinates to draw it. Efficiently have one draw call.
Issues: Managing the sf::Texture size, and content.

Question: Is it possible to clear area of render texture with RGB(0,0,0,0) ? because i want to reuse its position for new text that will be drawn
Figured out.

Also doing "sf::Texture::getMaximumSize()" returned 16384, is that pixel amount? 1D max size?
I googled, its per dimension if somebody wonders...
« Last Edit: August 13, 2014, 07:09:02 pm by BaneTrapper »
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0