How do I put multiple views to a render window?
I have this code:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow ventana(sf::VideoMode(300, 450, 32), "views",
sf::Style::Close);
ventana.setFramerateLimit(30);
sf::Sprite sprite;
sf::Texture texture;
texture.loadFromFile("asdf.png");
sprite.setTexture(texture);
sf::Sprite s_p;
sf::Texture t_p;
// 18x19
t_p.loadFromFile("per.png");
s_p.setTexture(t_p);
sf::View view1(sf::FloatRect(0, 0, 149, 149));
sf::View view2(sf::FloatRect(0, 0, 149, 149));
view2.setRotation(90);
sf::View view3(sf::FloatRect(0, 0, 149, 149));
view3.setRotation(180);
sf::View view4(sf::FloatRect(0, 0, 149, 149));
view4.setRotation(270);
sf::View view5(sf::FloatRect(0, 0, 149, 149));
view5.setRotation(45);
sf::View view6(sf::FloatRect(0, 0, 149, 149));
view6..zoom(0.5f);
for(int i = 0; i < 3600; i++)
{
ventana.clear();
ventana.draw(sprite);
ventana.display();
}
}
I want to have a 150x150 world, in wich i have only a background image or color (preferably, for the 45° degree rotated view), and to set the views in the window this way:
(http://imageshack.us/a/img197/5763/pos.png)
What I want is to display the same world with different perspectives.
Thank you.
window.setView(view1);
window.draw(world);
window.setView(view2);
window.draw(world);
window.setView(view3);
window.draw(world);
etc.
Finally I did it. Thank you very much. Now my issue is that... the rotated views are a little distorted...
(http://imageshack.us/a/img803/7677/pantallazo1a.png)
I think it is becouse the viewport dont have a exact size:
sf::View view1(sf::FloatRect(0, 0, 150, 150));
view1.setViewport(sf::FloatRect(0, 0, 0.5f, 0.33333f));
sf::View view2(sf::FloatRect(0, 0, 150, 150));
view2.setViewport(sf::FloatRect(0.5f, 0, 0.5f, 0.33333f));
view2.setRotation(90);
sf::View view3(sf::FloatRect(0, 0, 150, 150));
view3.setViewport(sf::FloatRect(0, 0.33333f, 0.5f, 0.33333f));
view3.setRotation(180);
sf::View view4(sf::FloatRect(0, 0, 150, 150));
view4.setViewport(sf::FloatRect(0.5f, 0.33333f, 0.5f, 0.33333f));
view4.setRotation(270);
sf::View view5(sf::FloatRect(0, 0, 150, 150));
view5.setViewport(sf::FloatRect(0, 0.66666f, 0.5f, 0.33333f));
view5.setRotation(45);
sf::View view6(sf::FloatRect(0, 0, 149, 149));
view6.setViewport(sf::FloatRect(0.5f, 0.66666f, 0.5f, 0.33333f));
view6.zoom(0.5f);
I mean 0.33333f... etc. Should I use 1/3?