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

Author Topic: SFML2: SetZoom in View?  (Read 3410 times)

0 Members and 1 Guest are viewing this topic.

tobybear

  • Newbie
  • *
  • Posts: 27
    • View Profile
SFML2: SetZoom in View?
« on: March 17, 2010, 01:08:23 pm »
Sorry, but upon quick glance at the SFML2 view functions, I can only see the Zoom() function for setting a zoom factor relative to the current one, but no SetZoom() function for setting an absolute one. Did I miss something or is it really not there?
For position change, Move() for relative change and SetPosition() for absolute change seems to work fine for example.

Also I noticed that I have to call "App.SetView(View);" after each change to zoom or position change of a view, else the view won't adapt to the changes. In the tutorial on this site for views it is mentioned that changes will be applied automatically? No big deal though, as I have to change/switch the view anyway several times during a frame update.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: SetZoom in View?
« Reply #1 on: March 17, 2010, 01:53:20 pm »
Quote
Sorry, but upon quick glance at the SFML2 view functions, I can only see the Zoom() function for setting a zoom factor relative to the current one, but no SetZoom() function for setting an absolute one. Did I miss something or is it really not there?
For position change, Move() for relative change and SetPosition() for absolute change seems to work fine for example.

Zoom internally modifies the size, there's no separate "zoom" member in views. So what you're looking for is SetSize.

Quote
Also I noticed that I have to call "App.SetView(View);" after each change to zoom or position change of a view, else the view won't adapt to the changes. In the tutorial on this site for views it is mentioned that changes will be applied automatically? No big deal though, as I have to change/switch the view anyway several times during a frame update.

This is the tutorial for SFML 1.x, it is highly deprecated for SFML 2. There's currently no documentation for SFML 2, but you can look at the API documentation which is in the headers. Or even build the API documentation yourself (in HTML or CHM format) with doxygen.
Laurent Gomila - SFML developer

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
SFML2: SetZoom in View?
« Reply #2 on: March 17, 2010, 03:30:38 pm »
I think tobybear was expecting the same interface as drawables has with Scale and SetScale  :wink:
Pluma - Plug-in Management Framework

tobybear

  • Newbie
  • *
  • Posts: 27
    • View Profile
SFML2: SetZoom in View?
« Reply #3 on: March 17, 2010, 03:45:58 pm »
Ok, thanks for the info, guys!

Using SetSize() I can easily write my own absolute zoom function by multiplying the window size with a given float (zoom) factor - great!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: SetZoom in View?
« Reply #4 on: March 17, 2010, 03:46:41 pm »
Quote
I think tobybear was expecting the same interface as drawables has with Scale and SetScale

I know, and it's equivalent: drawables have a scale, views have a size. Both have functions to reset it (SetScale, SetSize) and to modify it (Scale, Zoom). Zoom uses a factor, not an offset, but a Size(widthOffset, heightOffset) function would not make sense ;)
Laurent Gomila - SFML developer