Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Wrap of a GLScissors  (Read 2175 times)

0 Members and 1 Guest are viewing this topic.

overwave

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
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.
Laurent Gomila - SFML developer

overwave

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
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)));

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
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 ;)
Laurent Gomila - SFML developer

overwave

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
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 :(

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
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)

overwave

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
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