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

Author Topic: Weird Issue while trying to show text  (Read 1358 times)

0 Members and 1 Guest are viewing this topic.

Silverdagger

  • Newbie
  • *
  • Posts: 3
    • View Profile
Weird Issue while trying to show text
« on: February 16, 2017, 11:45:22 pm »
Hello, i am not decent at C++ but the following should work (but it doesn't)

//1 Doesnt work
sf::Text* ptxt = &dt->getElement(0);
std::cout << ptxt->getCharacterSize(); //size is printed correctly
ptxt->setCharacterSize(30);
std::cout << ptxt->getCharacterSize(); //size is changed correctly
ptxt->setString("No Sir");
window.draw(*ptxt); //Error

//2 Works
//sf::Text txt = dt->getElement(0);
//txt.setString("No sir");
//window.draw(txt);

//3 Works
//window.draw(dt->getElement(0));
 


I have a class that stores text on a vector and i fetch it in main for testing.
Although the example in the learning section of SFML works , parts 2 and 3 of the code work on their own - if i attempt to use the 1st part i get an error on the draw at runtime.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Weird Issue while trying to show text
« Reply #1 on: February 16, 2017, 11:52:05 pm »
It could be useful to provide a complete and minimal example that still causes this error.

Also, which error do you actually get? You seem to have forgotten to say.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Silverdagger

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Weird Issue while trying to show text
« Reply #2 on: February 17, 2017, 12:11:07 am »
Sorry i am new at this. If i run it via VS i get a breakpoint, if i realeashe and run the window just closes on me without any messege. The code here if you want to test.. https://www.dropbox.com/sh/b0o7ku05i8jbr2d/AADDODDgvdb-d8koi_GqC0mla?dl=0

Silverdagger

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Weird Issue while trying to show text
« Reply #3 on: February 17, 2017, 09:39:30 am »
Good new i found the problem - i did not have proper knowledge of the std::vector and was using it the wrong way hence the problem. But its fixed now .