Hi, I'm getting a really strange crash when trying to draw a sprite that is also a member of a class.
If I try this the program crashes with message "R6025 - pure virtual function call":
int MyClass::Run(void)
{
Texture tex;
if (!tex.loadFromFile("Image.png"))
return EXIT_FAILURE;
this->sprite = Sprite(tex);
while (window.isOpen())
{
//Ignore the lack of event-handling
window.clear();
window.draw(this->sprite);
window.display();
}
return EXIT_SUCCESS;
}
Commenting out this line "window.draw(sprite);" prevents it from crashing, but the window remains black as expected.
Additionally, if I simply replace this line "this->sprite = Sprite(tex);" with this line "Sprite sprite = Sprite(tex);" and update the draw call to match, the image is drawn successfully. It also works if I simply do this afterwards "Sprite sprite = this->sprite".
I really don't get why it crashes. It is the same sprite in all cases, the only difference is whether I use a local variable or a member variable in the draw call itself.