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

Author Topic: Change the View without having the source instance?  (Read 1526 times)

0 Members and 1 Guest are viewing this topic.

lapayo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Change the View without having the source instance?
« on: December 01, 2011, 02:54:36 pm »
Hello, I have a little poblem with zooming and moving the view.

Normally I would do the following:
Code: [Select]
sf::View CustomView;
App.SetView(CustomView);
CustomView.Zoom(1.5f);


But what if the current Class don´t knows the view?
Do i have to inject it?

I looked into RenderWindow and found the following:
GetView()
So I tried the following:
Code: [Select]
App->GetView().Zoom(1.5f);
But this gave me an error.
I also tried some casting:
Code: [Select]
((sf::View) App->GetView()).Zoom(1.5f);

This doesn´t produce a compiler error, but at runtime nothing happens.

Is there a way to get and change the current View?

Thanks in Advance,

Simon[/code]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Change the View without having the source instance?
« Reply #1 on: December 01, 2011, 02:56:33 pm »
Not in SFML 1.6, because sf::View instances had to be managed externally (so basically, SFML doesn't allow you to edit "someone else"'s view if you don't know "someone else" directly).

But in SFML 2 views are handled by copy, so you can get and set the current view from any location in the code.
Laurent Gomila - SFML developer

lapayo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Change the View without having the source instance?
« Reply #2 on: December 01, 2011, 04:23:05 pm »
Hey, thanks for your reply.
But how can I change it in SFML 2?
I have setup SFML 2 now, but I don´t get the view changed.

I tried the following:
Code: [Select]
((sf::View) App->GetView()).Zoom(1.5f);

//way number 2
sf::View View(App->GetView());
View.Zoom(1.5f);
App->SetView(View);


But boths methods are not working :(


EDIT: It was my fault. ;)
The second method is working. But my main-loop was resetting it always :D

Thanks for your help ;)

 

anything