SFML community forums
Help => Graphics => Topic started by: scorch on June 26, 2012, 07:41:29 pm
-
So, I'm trying to integrate SFML2 views into my game engine. It happens that I found some issues.
First, for what I've understood about views, I draw the objects and then I create Views and draw them, and they will draw the parts of the scene they are focused in. So, is it impossible to draw things differently in different views?
This because I wanted to draw somestuff in different positions depending on the view (in one view they might be at the center, and in another they might be in the left-upper corner). Also, I wanted to not show some stuff on some views and show it only in another.
I've searched and I found no way of doing this. :-[
-
I draw the objects and then I create Views and draw them
No. You draw objects and their final position depends on the current view. So you can draw an object several times with different views at different positions.
-
You can take a look at the 'Using sf::View' tutorial: http://en.sfml-dev.org/forums/index.php?topic=8334 (http://en.sfml-dev.org/forums/index.php?topic=8334)
-
I draw the objects and then I create Views and draw them
No. You draw objects and their final position depends on the current view. So you can draw an object several times with different views at different positions.
Ah ok, I read the tutorial eXpl0it3r posted, but I haven't understood very well how that hapened. So if I draw a sprite (0, 0) and then set another view and draw it again (5, 5) it will draw inside the view's viewport on (0, 0) and on the another at (5, 5), right? :)
You can take a look at the 'Using sf::View' tutorial: http://en.sfml-dev.org/forums/index.php?topic=8334 (http://en.sfml-dev.org/forums/index.php?topic=8334)
Thanks, but I already read that tutorial, that's the one I've used for understanding views in SFML. ;)
-
Ah okay, I thought I've explained everything quite good... :-\
I'm not sure what you're trying to achive. Can you ellaborate?
Do you want to create something like a split screen?
Have you taken a look at the completed demonstration at the end of the tutorial?
If you use two views you can set the viewports to position it in the right spot on the window, then you can just set view1, draw sprite1, then set view2 and draw sprite2 and sprite1 will get drawn to the viewport of view1 on the window and sprite2 will get drawn to the viewport of view2 on the window...
-
Ah okay, I thought I've explained everything quite good... :-\
The tutorial's fine. The problem is probably mine anyway, I didn't understood it very well but Laurent explained. :)
What I wanted was to draw layers. Sprites are grouped by layers. Then, some layers are visible to some views and aren't for others. I thought that we had to render everything and then each view would see what we'd rendered. But now I understand that we have to render what we want for each view, and that's what I wanted. :)