Hello,
The non spiltted window shows as this :
The entity that is drawn is the grid, it is a rectangur shape called RS, you will see it mentioned at the end of post.
I try to split the screen in half by having 2 views in the same window like this (view3b is the main view)
if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::D) // Double view
{
sf::View view3bSave=view3b; // i save a copy of the main view)
// player 1 (left side of the screen)
view3b.setViewport(sf::FloatRect(0.f, 0.f, 0.5f, 1.f));
window.setView(view3b);
// player 2 (right side of the screen)
view3bSave.setViewport(sf::FloatRect(0.5f, 0.f, 0.5f, 1.f));
window.setView(view3bSave);
}
And i get only the right part :
Then i read this post :
https://en.sfml-dev.org/forums/index.php?topic=11526.0Where it is expalained the "window.draw(world);" has to be done following each "setView".
I tried to draw the rectangular shape (the grid) RD, as following.
if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::D) // Double view
{
sf::View view3bSave=view3b;
// player 1 (left side of the screen)
view3b.setViewport(sf::FloatRect(0.f, 0.f, 0.5f, 1.f));
window.setView(view3b);
window.draw(RS);
// player 2 (right side of the screen)
view3bSave.setViewport(sf::FloatRect(0.5f, 0.f, 0.5f, 1.f));
window.setView(view3bSave);
window.draw(RS);
}
It did not work ! By the way here is the declaration of the main View :
sf::View view3b;
view3b.reset(sf::FloatRect(0.f, 0.f, 800.f, 800.f));
// its the size of the window.
What am i missing?