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

Author Topic: xtree error when trying to draw sf::Text  (Read 1281 times)

0 Members and 1 Guest are viewing this topic.

Canvas

  • Full Member
  • ***
  • Posts: 107
    • View Profile
xtree error when trying to draw sf::Text
« on: September 26, 2014, 12:58:13 am »
Hello there

I have myself a class that deals with loading fonts like so

#include "FontLoader.h"

FontLoader::FontLoader()
{

}

FontLoader::~FontLoader()
{

}

void FontLoader::LoadFont(GameStates state)
{
        //Load fonts
        Fonts[FontNames::Main_Font].loadFromFile("Assets/Fonts/Font.otf");
}

I then have a MainMenuState which is given a reference of my FontLoader like so

#include "MainMenuState.h"

MainMenuState::MainMenuState()
{

}

MainMenuState::~MainMenuState()
{

}

void MainMenuState::Setup(ImageLoader& imageLoaderSet, FontLoader& fontLoaderSet)
{
        TextObject textObject;
        textObject.Setup(200, 100, "Space Destroyer", 48, fontLoaderSet.Fonts[Main_Font]);
        textObject.SetRotationAnimation(-12, 12, 0.1);
        TextObjects.push_back(textObject);
}

This seems to write fine, but when I hit my draw function

void State::DrawTextObjects(sf::RenderWindow& window)
{
        for (int i = 0; i < TextObjects.size(); i++)
        {
                TextObjects.at(i).Draw(window);
        }
}

I get an error in Unhandled exception at 0x6292DCE2 (sfml-graphics-d-2.dll) in SpaceDestroyer.exe: 0xC0000005: Access violation reading location 0xCCCCCCD0, at

_Nodeptr _Pnode = _Root();

Am I passing the sf::Font the incorrect way?

Canvas

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: xtree error when trying to draw sf::Text
« Reply #1 on: September 26, 2014, 01:19:52 am »
its ok, I have changed my code to create a new textObject and push that into my vector and then set the values then, before I was creating a textobject, setting values and then pushing it back.

 

anything