SFML community forums

Help => Window => Topic started by: MrSnappingTurtle on August 16, 2014, 07:05:12 am

Title: Viewport not changing and stays at (0, 0)
Post by: MrSnappingTurtle on August 16, 2014, 07:05:12 am
Hi, I have the following code:

view.reset(sf::FloatRect(mainLevel->rooms[i]->roomSprite.getPosition().x, mainLevel->rooms[i]->roomSprite.getPosition().y, window.getSize().x, window.getSize().y));
window.setView(view);
std::cout << "Room Position: (" << mainLevel->rooms[i]->roomSprite.getPosition().x << ", " << mainLevel->rooms[i]->roomSprite.getPosition().y << ")" << std::endl;
std::cout << "Viewport: (" << window.getView().getViewport().left << ", " << view.getViewport().top << ")" << std::endl;
 

However, when I have the viewport position log, it is at (0, 0) when the room position is at (-75, -75). This happens even if I hardcode the (-75, -75) into it. Does anyone know why this happens? Thanks!
Title: Re: Viewport not changing and stays at (0, 0)
Post by: G. on August 16, 2014, 07:28:04 am
The viewport (http://www.sfml-dev.org/tutorials/2.1/graphics-view.php#defining-how-the-view-is-viewed) defines the area where the view is displayed inside your window. It is set with the setViewport method.
It doesn't relate to the view position in the world.