Hi guys.. first time poster..
I recently started using sfml and i seem to have come across a rather odd bug.. one that took me a little while to track down i may add
Im not new to c++ but it has been a few years since i coded in it..
so this may not be SFML's fault.. but ill explain and u can decide..
I started off by creating a class for my player.. i put an sf::Texture as one of its public variables..
now.. if i dont do anything with this texture, its fine.. i can pass the class to functions as much as i want and no errors.. the problem comes when i use
SF::TEXTURE.loadFromFile
no matter WHERE i load it from, INSIDE or OUTSIDE of the class.. once that texture has been initialised with that call.. i can no longer pass it to a function without INCREDIBLE slow down..
i did a small test, i placed a for loop with 900 cycles - inside it i placed a function that did literally NOTHING..
I then removed the code that initiated the texture with SF::Texture.LoadFromFile
i passed my CLASS to the function and ran the code, onscreen my little man runs around fine and smooth.
If i then put the code back to normal and let the texture initialise with the .LoadFromFile it basically stops my game running. I wondered if anyone else had come across this problem??
ill try and show a little better with some code.. just incase its confusing..
//Init code (ran only once at start of program)
sf::Texture MyText;
MyText.loadFromFile("sheet2.png"); // If i comment this out, it runs fine...
// If i leave it in then its slow..
// loopy test.
for (int p=0;p < 900;p++)
{
Redundant_func(MyText);
};