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

Author Topic: Can you put sf::Text into sf::VertexArray?  (Read 3453 times)

0 Members and 1 Guest are viewing this topic.

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Can you put sf::Text into sf::VertexArray?
« on: November 04, 2017, 10:11:17 pm »
Like the title says, is there a way to put sf::Text into a vertexarray?

For example let's say I'm using the tilemap example from the vertexarray tutorial, but I also want to have an sf::Text in the class. Is there a way to put the sf::Text into the vertex array so that the whole thing will have only one draw call?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Can you put sf::Text into sf::VertexArray?
« Reply #1 on: November 04, 2017, 10:19:58 pm »
No, you can't access the vertices of a sf::Text object.
Laurent Gomila - SFML developer

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Can you put sf::Text into sf::VertexArray?
« Reply #2 on: November 05, 2017, 01:54:30 am »
you could draw your text to a RenderTexture once, and extract its texture to use in your VertexArray.
but what are you trying to do, exactly?
Visit my game site (and hopefully help funding it? )
Website | IndieDB

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: Can you put sf::Text into sf::VertexArray?
« Reply #3 on: November 05, 2017, 07:02:37 am »
you could draw your text to a RenderTexture once, and extract its texture to use in your VertexArray.
but what are you trying to do, exactly?

Batch it into the vertexarray so that the whole class only has 1 draw call.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Can you put sf::Text into sf::VertexArray?
« Reply #4 on: November 05, 2017, 07:35:15 am »
Are you aware that everything drawn in a single call has to use the same texture? Which means that you would only be able to batch together sf::Text objects, that use the same font, same style and same character size.
Laurent Gomila - SFML developer

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: Can you put sf::Text into sf::VertexArray?
« Reply #5 on: November 11, 2017, 07:31:17 am »
you could draw your text to a RenderTexture once, and extract its texture to use in your VertexArray.

Does anybody have an example of this?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Can you put sf::Text into sf::VertexArray?
« Reply #6 on: November 11, 2017, 10:30:07 am »
Quote
Does anybody have an example of this?
That doesn't work for batching multiple texts together, unless you (can) render all your texts to a single big render-texture.

Regarding examples, you can start with the documentation and tutorials, and try something (it's not hard). Then if you're stuck let us know and show us what you've already done.
Laurent Gomila - SFML developer