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

Author Topic: Textured text?  (Read 3236 times)

0 Members and 1 Guest are viewing this topic.

mateandmetal

  • Full Member
  • ***
  • Posts: 171
  • The bird is the word
    • View Profile
    • my blog
Textured text?
« on: December 18, 2012, 09:36:38 pm »
Can sf::Text use a texture instead of a solid fill color?

  sf::Text myText ("Hello!", myFont, 35);
  myText.setTexture (myTexture);
 

I know sf::Shape has a setTexture method. Can sf::Text have one?  ::)
- Mate (beverage) addict
- Heavy metal addict _lml
- SFML 2 addict
- My first (and free) game: BichingISH!

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: Textured text?
« Reply #1 on: December 18, 2012, 10:26:28 pm »
Each glyph of an sf::Text is really a quad, not an actual character geometry. This means that we can only specify the texcoords of the corners, which we already use to map the actual character in the font texture.

In conclusion, that effect is impossible with the current API, and without a major break in the way that sf::Text and sf::Font work..

Maybe you could achieve it with a pixel shader testing the text geometry by its color and assigning a texture coordinate?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Textured text?
« Reply #2 on: December 18, 2012, 10:40:56 pm »
What's the use case for textured text? Why do you need it?
Laurent Gomila - SFML developer

Chris12

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Textured text?
« Reply #3 on: December 19, 2012, 11:14:53 am »
Use a shader to directly merge the two textures (the glyphs and your custom texture) in a single drawcall.
or if that doesnt work draw the text with white color, then in a second pass, apply your texture on all white pixels.

mateandmetal

  • Full Member
  • ***
  • Posts: 171
  • The bird is the word
    • View Profile
    • my blog
Re: Textured text?
« Reply #4 on: December 19, 2012, 05:15:14 pm »
Thanks Devil, Chris, but I know nothing about GLSL programming  :-[
Laurent: I want to display textured text in different languages. The strings are loaded from the .xml file at runtime.
- Mate (beverage) addict
- Heavy metal addict _lml
- SFML 2 addict
- My first (and free) game: BichingISH!