1
Graphics / ViewPort not working correctly?
« on: May 11, 2013, 07:04:05 pm »
Hello, I am trying to display a full screen image using Views. This is my code:
The result is this: http://db.tt/14sjmZol. As you can see it is not using the full screen and my image is cutted on right (this is the original image: http://db.tt/5Q6D3uN5). Why this happens? Isn't it suppose to show me the full image on the window ?
sf::RenderWindow mWindow(sf::VideoMode(800,600), "Prueba Animaciones");
// Cargo la imagen y muestro un pedazo
sf::Texture mBGTexture;
sf::Sprite mBGSprite;
if(!mBGTexture.loadFromFile("bg_big.png")) return EXIT_FAILURE;
mBGSprite.setTexture(mBGTexture);
imageWidth = mBGTexture.getSize().x;
imageHeight = mBGTexture.getSize().y;
sf::CircleShape mBall;
mBall.setRadius(10.0);
mBall.setFillColor(sf::Color::White);
sf::View miniMap;
miniMap.setSize(imageWidth, imageHeight);
miniMap.setViewport(sf::FloatRect(0, 0, 1, 1));
mWindow.setFramerateLimit(60);
while(mWindow.isOpen()){
mWindow.clear();
mWindow.setView(miniMap);
mWindow.draw(mBGSprite);
mWindow.draw(mBall);
mWindow.display();
}
// Cargo la imagen y muestro un pedazo
sf::Texture mBGTexture;
sf::Sprite mBGSprite;
if(!mBGTexture.loadFromFile("bg_big.png")) return EXIT_FAILURE;
mBGSprite.setTexture(mBGTexture);
imageWidth = mBGTexture.getSize().x;
imageHeight = mBGTexture.getSize().y;
sf::CircleShape mBall;
mBall.setRadius(10.0);
mBall.setFillColor(sf::Color::White);
sf::View miniMap;
miniMap.setSize(imageWidth, imageHeight);
miniMap.setViewport(sf::FloatRect(0, 0, 1, 1));
mWindow.setFramerateLimit(60);
while(mWindow.isOpen()){
mWindow.clear();
mWindow.setView(miniMap);
mWindow.draw(mBGSprite);
mWindow.draw(mBall);
mWindow.display();
}
The result is this: http://db.tt/14sjmZol. As you can see it is not using the full screen and my image is cutted on right (this is the original image: http://db.tt/5Q6D3uN5). Why this happens? Isn't it suppose to show me the full image on the window ?