I have my own Text class which uses sf::Text to display text on the screen.

First I couldn't get the text to display on the screen, my solution was that I forgot to give the text a font before displaying it.

So I gave the text a font, which lead to a complete crash.

All it gave me was some pretty useless information :

Unhandled exception at 0x0FFC2AA4 (sfml-graphics-d-2.dll) in SFML_Game.exe: 0xC0000005: Access violation reading location 0x0000000D.

My game crashed at this line of code :


And my window variable is this :

Text::Text(sf::RenderWindow* _window, char* _text, int size, sf::Vector2f position, float rotation, sf::Color color, int style, char* PATH)
    this->window = _window; 

// (more code.........)

My window variable is of this type :

sf::RenderWindow* window;

When the constructor of my Text class is called, it has these parameters :

&window, "I am just a text. :]", 24, sf::Vector2f(100, 100), 0, sf::Color::White, sf::Text::Style::Bold, "Res/Fonts/arial.ttf"

I've checked the font, it seems to load properly.

Also, not sure if it matters but my Text object is stored inside of a std::vector .... :

texts.push_back(Text(&window, "I am just a text. :]", 24, sf::Vector2f(100, 100), 0, sf::Color::White, sf::Text::Style::Bold, "Res/Fonts/arial.ttf"));

Texts does render by just creating a sf::Font and sf::Text and rendering it.

So, I did this :

Picture. ---Not sure if this means anything at all... :3

Also noticed that sometimes I get a Microsoft Visual C++ Runtime Library crash.


And if I press retry it triggers a breakpoint.

  • 1
    \$\begingroup\$ You should try a step by step debugger and find which of the variable is null. \$\endgroup\$ – Vaillancourt Dec 28 '15 at 6:36
  • \$\begingroup\$ @AlexandreVaillancourt Don't know what that is, couldn't find any help on google either :( \$\endgroup\$ – BiiX Dec 28 '15 at 12:00
  • \$\begingroup\$ @AlexandreVaillancourt Found out what step debugging is, window->draw(text); is the problem, and as my updated posts picture says, I can for some reason not see what the variable text is. :/ \$\endgroup\$ – BiiX Dec 29 '15 at 15:34
  • \$\begingroup\$ It will be hard to give a definitive answer to this question as it's unclear what you're doing. As I suggested in another question of yours, I would suggest you use pointers instead of raw variable for your SFML objects. Also, the code texts.push_back(Text(&window should probably be texts.push_back(Text(window: you seem to be passing a reference to a pointer instead of a pointer. And to improve your debugging, you would need the PDBs for the SFML along the DLL. \$\endgroup\$ – Vaillancourt Dec 30 '15 at 23:35
  • \$\begingroup\$ @AlexandreVaillancourt Will try this asap. :> \$\endgroup\$ – BiiX Dec 31 '15 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.