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

Author Topic: Can't seem to use sf::View  (Read 1033 times)

0 Members and 1 Guest are viewing this topic.

jagoly

  • Newbie
  • *
  • Posts: 4
    • View Profile
Can't seem to use sf::View
« 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 (line 69)

I'm running Ubuntu 14.04, with stable SFML 2.1 from the repos.

jagoly

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Can't seem to use sf::View
« Reply #1 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

jagoly

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Can't seem to use sf::View
« Reply #2 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?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Can't seem to use sf::View
« Reply #3 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().
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: