Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Graphics
»
Wrap of a GLScissors
Print
Pages: [
1
]
Author
Topic: Wrap of a GLScissors (Read 2175 times)
0 Members and 1 Guest are viewing this topic.
overwave
Newbie
Posts: 4
Wrap of a GLScissors
«
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.
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: Wrap of a GLScissors
«
Reply #1 on:
June 08, 2015, 12:18:25 pm »
Until
it is implemented properly
, you can fake it with a sf::View whose size and viewport are both set to the clipping area.
Logged
Laurent Gomila - SFML developer
overwave
Newbie
Posts: 4
Re: Wrap of a GLScissors
«
Reply #2 on:
June 08, 2015, 03:14:03 pm »
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)));
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: Wrap of a GLScissors
«
Reply #3 on:
June 08, 2015, 03:31:31 pm »
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
Logged
Laurent Gomila - SFML developer
overwave
Newbie
Posts: 4
Re: Wrap of a GLScissors
«
Reply #4 on:
June 08, 2015, 05:36:53 pm »
But when I initialize sf::View I don't set the Viewport? Also, due to my low english I got documentation not so clear
Logged
SpeCter
Full Member
Posts: 151
Re: Wrap of a GLScissors
«
Reply #5 on:
June 08, 2015, 05:53:48 pm »
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)
Logged
overwave
Newbie
Posts: 4
Re: Wrap of a GLScissors
«
Reply #6 on:
June 08, 2015, 07:53:16 pm »
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
Logged
Print
Pages: [
1
]
SFML community forums
»
Help
»
Graphics
»
Wrap of a GLScissors