Hello Everyone!!
I'm having troubles rendering text on the screen. When my renderedwindow instance call draw method using a sf::Text instance as a parameter, i got a memory access violation message in MS VS 2012 c++
I'm using sfml 2.1 and I have triple checked that I'm not using the debug libraries.
here is my code:
class MyClass{
void Initialize(){
mWindow = new new sf::RenderWindow();
sf::Font myFont ;
if (!myFont.loadFromFile("arial.ttf"))
{
//Throw error
}
text = new sf::Text();
text->setFont(myFont);
text->setCharacterSize(50);
text->setPosition(250,250);
text->setColor(sf::Color::Red);
// set the text style
text->setStyle(sf::Text::Bold | sf::Text::Underlined);
text->setString("Hello world");
}
void draw(){
mWindow->clear();
mWindow->draw(*text); // this line throw the memory access violation message
mWindow->display();
}
}
private:
sf::RenderWindow* mWindow;
sf::Text* text;
}
void main(){
MyClass* mclass = new MyClass();
mclass->Initialize();
//game loop
while (......) {
mclass->draw();
}
}
the error is :
Unhandled exception at 0x51C12E59 (sfml-graphics-2.dll) in CDIAZ_2DENGINE.exe: 0xC0000005: Access violation reading location 0x3F800004.
I'll appreciate the help!