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

Show Posts

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.


Messages - sheep

Pages: [1]
1
General / Re: Passing a sf::Texture instance to a function is slow
« on: May 11, 2013, 03:19:04 pm »
hey man.. yeah sorry about that.. didnt mean to be a scare monger.. couldnt think of any other title at the time(5am) ;p .. will check better next time.. i assumed it would have been more ignorance on my part than a bug on urs.. great library.. tnx for the effort and time you put in..

cheers matey..

hey corn - tnx for reply m8y

2
General / Passing a sf::Texture instance to a function is slow
« on: May 11, 2013, 07:17:05 am »
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);

};



Pages: [1]