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

Author Topic: Drawing to 2 views simultaniously  (Read 1276 times)

0 Members and 1 Guest are viewing this topic.

Uzaku

  • Newbie
  • *
  • Posts: 8
    • View Profile
Drawing to 2 views simultaniously
« on: September 30, 2014, 02:18:37 pm »
Hey,
I've got a question regarding the view-tutorial.
As far as I understood it, when I want to have a minimap, I need a normal view for my character, which will be moved when the character moves (do I really have to call Window::setView() every time I want to move it?)
And then I need one for my minimap, which simply covers the complete space of my level, instead of the monitor resolution.
To display them I call setView with the playerView, draw my 100+ level-objects, and then i call setView with the minimap-view and draw them all again?
Is that how it is?
Isn't there a way to just call draw once for every level-object? Otherwise that would mean, that the runtime depends linear on the number of views?

And another question:
can I just call draw for every object, in my level, or should I first check which one will be in the window anyway, and only call draw for those ones?

greetings Uzaku

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Drawing to 2 views simultaniously
« Reply #1 on: September 30, 2014, 02:32:33 pm »
Quote
do I really have to call Window::setView() every time I want to move it?
Yes, what you change is a copy of the current view, it is really applied only when you call setView.

Quote
To display them I call setView with the playerView, draw my 100+ level-objects, and then i call setView with the minimap-view and draw them all again?
Is that how it is?
Yes. But usually the minimap contains only the background, possibly with points or arrows for the various entities. You never draw your entities' sprites directly to the minimap -- at this size, they would end up like single points or small rectangles anyway.

What you can do is pre-render your map in a sf::RenderTexture and just draw the result with a single sprite to display the mini-map.

Quote
Isn't there a way to just call draw once for every level-object?
No. If you see something twice on screen, obviously it needs to be drawn twice... ;)

Quote
can I just call draw for every object, in my level, or should I first check which one will be in the window anyway, and only call draw for those ones?
If you have performances issues, this can be a good optimization strategy. But only after you have measured that this really impacts your performances.
Laurent Gomila - SFML developer

Uzaku

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Drawing to 2 views simultaniously
« Reply #2 on: September 30, 2014, 02:50:36 pm »
Alright, thanks for your answer :D