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

Author Topic: how to properly to use this shader?  (Read 9000 times)

0 Members and 1 Guest are viewing this topic.

Rhimlock

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: how to properly to use this shader?
« Reply #15 on: October 10, 2013, 04:02:12 pm »
Just a guess:

What height does texture have after you set it to your render texture at the end?

texture = render_texture.getTexture();

How do you draw those textures? Maybe your sprite's height is limited to the original fonts height.

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: how to properly to use this shader?
« Reply #16 on: October 10, 2013, 04:21:50 pm »
well, it's exactly the same from render_texture.
by using
std::cout << "\ntexture size:" << texture.getSize().x << "," << texture.getSize().y;
after the last line, i get
Quote
text size:344,65
render_texture size:364,85
texture size:364,85

i think that something is wrong when creating the RenderTexture size.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: how to properly to use this shader?
« Reply #17 on: October 10, 2013, 04:37:47 pm »
Try changing

render_texture.create(text.getGlobalBounds().width + outline_thickness*2, text.getGlobalBounds().height + outline_thickness*2);

To

render_texture.create(text.getGlobalBounds().width + outline_thickness*4, text.getGlobalBounds().height + outline_thickness*4);
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: how to properly to use this shader?
« Reply #18 on: October 10, 2013, 04:53:55 pm »
yeah, i tried it. for some reason, i get the best results with

    render_texture.create(text.getGlobalBounds().width + outline_thickness*2, text.getGlobalBounds().height + outline_thickness*4);
and
    text.setPosition(outline_thickness, 0);
what does not make any sense to me. the horizontal bounds are perfect. but the vertical is nonsense. maybe it's something related to the font usage...
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: how to properly to use this shader?
« Reply #19 on: October 10, 2013, 06:36:37 pm »
Use bounds.left + bounds.width (same on Y). Don't assume that left and top are always zero, they are not for sf::Text.
Laurent Gomila - SFML developer

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: how to properly to use this shader?
« Reply #20 on: October 11, 2013, 12:02:40 am »
do you mean something like this?
float texture_width = text.getGlobalBounds().left + text.getGlobalBounds().width + outline_thickness*2;
float texture_height = text.getGlobalBounds().top + text.getGlobalBounds().height + outline_thickness*2;
render_texture.create(texture_width, texture_height);

much better. but it still cuts a bit of the text (look below the "G" and "T")


BUT all the fonts works if i use the line
text.setPosition(outline_thickness, 0);
instead of
text.setPosition(outline_thickness, outline_thickness);

although if we don't have an explanation, it's good enough for me, as it's working :P
Visit my game site (and hopefully help funding it? )
Website | IndieDB

 

anything