sure, i'll do it as soon as i have it polished.
right now i'm trying to optimize it, but had some issues. what i'm trying to do is create a new texture based on the outlined text, so i don't have to make so many copies of the text to re-draw the outline every frame. here is the code:
void createOutline(sf::Texture &texture, sf::Text &text, sf::Color outline_color, float outline_thickness, int smooth){
sf::RenderTexture render_texture;
render_texture.create(text.getGlobalBounds().width + outline_thickness*2, text.getGlobalBounds().height + outline_thickness*2);
render_texture.clear(sf::Color::Transparent);
text.setPosition(outline_thickness, outline_thickness);
std::cout << "\ntext size:" << text.getGlobalBounds().width << "," << text.getGlobalBounds().height;
std::cout << "\nrender_texture size:" << render_texture.getSize().x << "," << render_texture.getSize().y;
sf::Text outline = text;
outline.setColor(outline_color);
const float pi = 3.1415;
for (int theta = 0; theta <= 360; theta += smooth){
float pos_x = std::cos(theta*pi/180.0) * outline_thickness;
float pos_y = std::sin(theta*pi/180.0) * outline_thickness;
outline.setPosition(text.getPosition() + sf::Vector2f(pos_x, pos_y));
render_texture.draw(outline);
}
render_texture.draw(text);
render_texture.display();
texture.create(render_texture.getTexture().getSize().x, render_texture.getTexture().getSize().y);
texture = render_texture.getTexture();
instead of getting a sf::Window as first argument, i get a sf::Texture. then i create a RenderTexture, draw the text to it, and copy it's texture at the end. drawing a single Texture is much lighter than drawing 72 black texts to create the outline effect, i believe.
but i'm getting a weird result. i don't know if its something related to the font or my code, but even if i change the font i still get this:
the texture is not being cut in the right place. hrere is the output (from the two std::cout lines):
text size:344,65
render_texture size:364,85
any idea why? maybe i did something wrong in the calculations
thanks!