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

Author Topic: Problem with drawing text  (Read 2587 times)

0 Members and 1 Guest are viewing this topic.

excentio

  • Newbie
  • *
  • Posts: 21
    • View Profile
Problem with drawing text
« on: November 16, 2014, 07:47:47 pm »
Hello guys, I have a problem when I'm trying to draw more than one sf::Text, here's my source code
void GUI::CreateButton(sf::Vector2f position, sf::Vector2f size, sf::String text, sf::Vector2f textPos, sf::Texture buttonIMG, sf::Texture buttonGUIDANCE, sf::Texture buttonCLICK)
{
        std::unique_ptr<buttonSettings> rect (new buttonSettings()); // Creating a pointer to struct
 
                font.loadFromFile("D:\\visual studio 2012\\SFML_engine\\Project1\\Release\\Kingthings_Serifique.ttf");
        rect->btns.setPosition(position);

                rect->buttonIMG = buttonIMG;
                rect->buttonGUIDANCE = buttonGUIDANCE;
                rect->buttonCLICK = buttonCLICK;

               
        rect->btns.setSize(size);
                rect->btnText.setFont(font);
                rect->btnText.setCharacterSize(12);
                rect->btnText.setString(text);
                rect->btnText.setPosition(textPos);
        buttons.push_back(std::move(rect));
}

and then, after I've created a button with text, I'm drawing it :

for(unsigned int b = 0; b<buttons.size(); b++) { // draw buttons
                                _window.draw(buttons[b]->btns);
                                _window.draw(buttons[b]->btnText);
        }

and here, how my struct looks :

  typedef struct buttonSettings {
        sf::RectangleShape btns;
                sf::Text btnText;
                sf::Texture buttonIMG;
                sf::Texture buttonGUIDANCE;
                sf::Texture buttonCLICK;
        };

        std::vector<std::unique_ptr<ButtonListSettings>> buttonList;
 
all works fine, except one thing, when I'm creating more than one button with text, it's.. doing some strange things with one text.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
AW: Problem with drawing text
« Reply #1 on: November 16, 2014, 07:51:33 pm »
Can you create a minimal and complete example which reproduces the issue?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

excentio

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: AW: Problem with drawing text
« Reply #2 on: November 16, 2014, 07:54:14 pm »
Can you create a minimal and complete example which reproduces the issue?
thanks for reply, under complete example, you mean show the full code ? And what do you mean under "minimal" example ?

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: Problem with drawing text
« Reply #3 on: November 16, 2014, 08:24:52 pm »
The least amount of possible working code (minus everything irrelevant to the problem) that reproduces your problem as stated in this post: http://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368 .

excentio

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Problem with drawing text
« Reply #4 on: November 16, 2014, 08:27:18 pm »
oh, thanks

excentio

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Problem with drawing text
« Reply #5 on: November 16, 2014, 08:40:14 pm »
lol, guys, thanks for help, I'm moron, I was always rendering the same sf::Text in cycle :c

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Problem with drawing text
« Reply #6 on: November 16, 2014, 09:53:52 pm »
This is why I like the complete and minimal thing: people normally notice their own problems when thinning out stuff  ;D
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*