SFML community forums
Help => Graphics => Topic started by: Uzaku 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
-
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.
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.
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... ;)
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.
-
Alright, thanks for your answer :D