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

Author Topic: Different views showing diferent stuff  (Read 3370 times)

0 Members and 1 Guest are viewing this topic.

scorch

  • Newbie
  • *
  • Posts: 17
    • View Profile
Different views showing diferent stuff
« 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.  :-[

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Different views showing diferent stuff
« Reply #1 on: June 26, 2012, 08:56:35 pm »
Quote
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.
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: Different views showing diferent stuff
« Reply #2 on: June 26, 2012, 09:23:36 pm »
You can take a look at the 'Using sf::View' tutorial: http://en.sfml-dev.org/forums/index.php?topic=8334
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

scorch

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Different views showing diferent stuff
« Reply #3 on: June 26, 2012, 10:00:57 pm »
Quote
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
Thanks, but I already read that tutorial, that's the one I've used for understanding views in SFML.  ;)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: Different views showing diferent stuff
« Reply #4 on: June 26, 2012, 11:07:22 pm »
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...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

scorch

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Different views showing diferent stuff
« Reply #5 on: June 27, 2012, 09:44:05 am »
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. :)