SFML community forums

Help => Graphics => Topic started by: jagoly on May 29, 2014, 08:35:45 am

Title: Can't seem to use sf::View
Post by: jagoly on May 29, 2014, 08:35:45 am
Hi. In my project, I'm trying to get window resizing working as I want it, with an sf::View. The problem line is:
window->setView(sf::View({0, 0, static_cast<float>(size.x), static_cast<float>(size.y)}));
Where size is a vector2u, from the resize event. replacing them with any static value also does the same thing. window is a pointer to an sf::RenderWindow.

What happens is, upon reaching this line, the application will segfault. Am I using this class completely wrong, or is there some other issue? The full project is on launchpad, the file with this error is here: http://bazaar.launchpad.net/~james-gangur/sqee/exp/view/head:/libsqee/app/application.cpp (http://bazaar.launchpad.net/~james-gangur/sqee/exp/view/head:/libsqee/app/application.cpp) (line 69)

I'm running Ubuntu 14.04, with stable SFML 2.1 from the repos.
Title: Re: Can't seem to use sf::View
Post by: jagoly on May 29, 2014, 08:46:56 am
ummmm
Sorry for the spam. I was trying to set the view of the window pointer before I had actually initialized it. Sorry :P
Title: Re: Can't seem to use sf::View
Post by: jagoly on May 29, 2014, 11:16:15 am
Actually, still on the same problem:
If I change the texture of an sf::sprite, shouldn't it's size change to match the texture? Otherwise, I'd need to create a new sprite every time I render. Or, how would I go about doing that when resizing?
Title: Re: Can't seem to use sf::View
Post by: Nexus on May 29, 2014, 11:29:55 am
If I change the texture of an sf::sprite, shouldn't it's size change to match the texture?
Please read the documentation of sf::Sprite::setTexture().