SFML community forums
Help => Graphics => Topic started by: overwave on June 08, 2015, 12:09:25 pm
-
In simple GL i had Scissors to change a rectangle for drawing. Which analog exists in SFML?
Scheme is attached.
-
Until it is implemented properly (https://github.com/SFML/SFML/issues/1), you can fake it with a sf::View whose size and viewport are both set to the clipping area.
-
Maybe I don't understand something, but I don't know hot to do this:
window->draw(sprite);
window->setView(sf::View(sf::FloatRect(posX, posY, wid, hei)));
window->draw(text);
window->setView(sf::View(sf::FloatRect(0, 0, 800, 600)));
-
You set the view correctly, now you must do the same with its viewport. Have a look at the doc and tutorials if you don't know what I'm talking about ;)
-
But when I initialize sf::View I don't set the Viewport? Also, due to my low english I got documentation not so clear :(
-
You only set the View, size and position to be exact.
The viewport is more or less where it is supposed to be on screen.
So you have to call setViewport to do that. Keep in mind that the Viewport coordinates are relative(0-1)
-
sf::View reduced(sf::FloatRect(posX, posY, wid, hei));
reduced.setViewport(sf::FloatRect((float)posX / 800.f, (float)posY / 600.f, (float)wid / 800.f, (float)hei / 600.f));
<3
Solved