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

Author Topic: View ports  (Read 1516 times)

0 Members and 1 Guest are viewing this topic.

Antonio9227

  • Newbie
  • *
  • Posts: 25
    • View Profile
View ports
« on: November 12, 2013, 04:24:02 pm »
I am trying to add a minimap to my game. I already used views for moving cameras, but I can't figure out how to use viewports. I know what they are supposed to do, but I still can't figure it out.

Here is what I was trying to do. I have "view" which is what I'm using for the game and "minimap" which should be the minimap.
view.setViewport(sf::FloatRect(0,0,1,1));
sf::View minimap;
minimap.reset(sf::FloatRect(0,0,level.x*56,level.y*56));
minimap.setViewport(sf::FloatRect(0.75f, 0, 0.25f, 0.25f));
They are working separately, if I bind one of them to my window ( window.setView(view); ) it works, but I can't figure out how to display them both. I searched on google but I couldn't find anything usefull.

If you can help me, leave a reply below.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: View ports
« Reply #1 on: November 12, 2013, 04:28:35 pm »
window.setView(view);

// draw level ...

window.setView(minimap);

// draw minimap ...
Laurent Gomila - SFML developer

Antonio9227

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: View ports
« Reply #2 on: November 12, 2013, 04:48:49 pm »
Well it was... incredibly easy...  XD

Thanks mate.