Just wanted to share an experience I am having with SFML.
I've come to realize that the library doesn't implement move semantics. Move semantics are used to avoid copying so much data around when dealing with temporaries, but I'm not hear to explain how it works.
Here's an example of what I tried to do:
m_loginWindow = LoginWindow( Win.getSize(), m_arialFont );
What suppose to happen is, the LoginWindow(Win.getSize(), m_arialFont ) creates a temporary LoginWindow object, then assigns it to m_loginWindow. Everything should have been moved over, or so I thought. Well, the pointer to the texture I set in the temp didn't carry over to the persistent version(m_loginWindow). So I ended up making my own move assignment operator by operator overloading ( LoginWindow &operator=(LoginWindow &&Src); )
After explicitly specifying that I want to move everything over, I ran it again only to find that this still didn't work and sf::Sprite still lost the pointer to the texture. I checked that the texture is still there and valid, it was, so I ended up just setting the texture again and voila, it now draws the sprite.
m_bgSprite.setTexture(m_bgTexture);
Move semantics would be a good things for the lib devs to implement, as well as making a constructor for loading fonts from file. So far those are the only issues I've run into with graphics.
As for the networking stuff, I think move semantics would be good there also since they're not copyable. To use sf::TcpSocket in a vector, you must first wrap them in a unique_ptr for instance.
std::vector<std::unique_ptr<sf::TcpSocket>> socketList;
socketList.push_back( std::make_unique<sf::TcpSocket>() );
Anyway, any other tips I find I'll share here, feel free to add your own.
SFML encounters
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
SFML encounters
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: SFML encounters
I ran into the same issues as well with sf::Sprite. All in all though, I found sfml pretty easy to use. I haven't tried any networking stuff as i had no need to.
Curiosity killed the cat, satisfaction brought him back
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: SFML encounters
Really beginning to take issue with this no move semantics lol.
Apparently sf::String doesn't like to be moved either.
Oh well, just more work for me.
Well, maybe I jumped the gun on that one. I may not have debugged far enough to determine if that was the case. Either way, ended up just making my own move assignment operator.
Apparently sf::String doesn't like to be moved either.
Oh well, just more work for me.
Well, maybe I jumped the gun on that one. I may not have debugged far enough to determine if that was the case. Either way, ended up just making my own move assignment operator.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: SFML encounters
This is good stuff to know. I like sfml a lot, but it is far from perfect. Still, I plan on doing a few videos on it in the future.
Chili