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

Author Topic: moving sf::View from sf::RenderWindow  (Read 1774 times)

0 Members and 1 Guest are viewing this topic.

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
moving sf::View from sf::RenderWindow
« on: September 09, 2013, 06:54:46 pm »
hello everybody
is there any way to directly move the view copy stored in the window object?
sf::RenderWindow window;
sf::View view;

view.setCenter(sf::Vector2f(100, 0));
view.setSize(400, 400);
window.create(sf::VideoMode(400,400), "Test!");
window.setView(view);
 

according to this topic, i should call this line every time the view is changed, but it made my cpu usage go from less than 1% to about 48%
window.setView(view);

so, isn't there any way to directly move the view copy stored in the window object?
thanks in advance!
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: moving sf::View from sf::RenderWindow
« Reply #1 on: September 09, 2013, 06:59:32 pm »
is there any way to directly move the view copy stored in the window object?
No.

but it made my cpu usage go from less than 1% to about 48%
I really doubt that the setView() call is the cause for the higher CPU usage. You should measure with a profiler, not with the task manager or top. Otherwise, can you reproduce the issue in a minimal example?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: moving sf::View from sf::RenderWindow
« Reply #2 on: September 10, 2013, 12:42:17 am »
you are absolutely right. the problem was moving the view in a big tiled world.
i changed the code a bit, so it now only renders around the view. altough the CPU usage goes up a little bit, it stays under 8%.

thanks for the tip on Profilers. i really was getting the information from lxtask :)
Visit my game site (and hopefully help funding it? )
Website | IndieDB

 

anything