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

Author Topic: Trouble with views  (Read 2643 times)

0 Members and 1 Guest are viewing this topic.

Puck

  • Newbie
  • *
  • Posts: 8
    • View Profile
Trouble with views
« on: July 18, 2008, 04:50:28 pm »
This isn't necessarily a problem with SFML, but more a request for help. what I'm trying to do is create a 352x352 pixel view inside of a 640x480 window in the top left corner that can scroll separately from the main window.

The obvious solution to me would be to use an sf::View, but I don't understand views at all. What exactly are the "Center" and "Half Width" parameters? I assumed they were the position of the "window" into whatever I'm drawing after the view is set, so I did something like this:

Code: [Select]
View LevelView(Vector2f(176,176), Vector2f(176, 176));

while (SFMLApp.IsOpened()) {
//Process events
while (SFMLApp.GetEvent(input)) {
//(...)
}

SFMLApp.SetView(LevelView);
SFMLApp.Draw(testlevel);
SFMLApp.Draw(Player);
SFMLApp.SetView(SFMLApp.GetDefaultView());
}


Instead what I get is this:



As you can see, the content of the view is stretched in strange ways. I read the View tutorial a few times, read the source for it a few times, and as far as I can tell there's no way to make a view that only takes up part of the screen. Is that true? Are views incomplete or am I misunderstanding their purpose? :?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Trouble with views
« Reply #1 on: July 18, 2008, 04:59:16 pm »
A view simply defines which region of your "scene" to map to the window area. So yes it will always be stretched, and no you can't have a rendering region smaller than the window (this is a completely different topic).

However it's easy to achieve : just draw a colored sprite or shape on top of the view to create your "non rendered" region.
Laurent Gomila - SFML developer

Puck

  • Newbie
  • *
  • Posts: 8
    • View Profile
Trouble with views
« Reply #2 on: July 18, 2008, 05:02:17 pm »
Ah, thanks. Apparently I did misunderstand the purpose of views (ie, they were for things like "split-screen"). I'll just use some kind of "fake" scrolling instead. Thanks! :)