1
Graphics / Displaying sf::String from a pointer
« on: May 17, 2010, 07:36:09 pm »
Aww go to hell : C You just came and solved it in a second. Yep, works fine, thanks : P
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
It solved the crash that was caused by a GetDefaultFont()
CText::CText(void)
{
this->m_string.SetText("Hello");
sf::Font f;
if(!f.LoadFromFile("fonts\\arial.ttf", 50))
{
this->m_string.SetText("Font load failure");
}
else
{
this->m_string.SetText("Font loaded successfully");
this->m_string.SetFont(f);
this->m_string.SetSize(40.f);
}
this->m_string.SetColor(sf::Color(0,0,0));
}
void CText::D(sf::RenderTarget &target)
{
target.Draw(m_string);
}
this->m_string.SetFont(f);
sf::String sfSString;
sf::Font f;
if(!f.LoadFromFile("fonts\\arial.ttf", 50))
{
sfSString.SetText("Font load failure");
}
else
{
sfSString.SetText("Font loaded successfully");
sfSString.SetFont(f);
sfSString.SetSize(40.f);
}
CText(sf::Font& f) : m_string("Sometext", f, 40.f) {}
sf::Font _fnt;
_fnt.LoadFromFile("arial.ttf");
CText Foobar(_fnt);
CText()
{
sf::Font _font;
_font.LoadFromFile("arial.ttf");
this->m_string = new sf::String("Text", _font, 40.f);
}
void Draw(sf::RenderTarget &target)
{
target.Draw(*m_string);
}