SFML community forums

Help => Graphics => Topic started by: Puck on July 18, 2008, 04:50:28 pm

Title: Trouble with views
Post by: Puck 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:

(http://img147.imageshack.us/img147/237/examplewq7.th.jpg) (http://img147.imageshack.us/my.php?image=examplewq7.jpg)

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? :?
Title: Trouble with views
Post by: Laurent 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.
Title: Trouble with views
Post by: Puck 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! :)